Problem:
Rabbit Party
A rabbit Taro decided to hold a party and invite some friends as guests.
He has
n
rabbit friends, and
m
pairs of rabbits are also friends with each other.

Friendliness of each pair is expressed  with a positive integer.
If two rabbits are not friends, their friendliness is assumed to be 0.
When a rabbit is invited to the party, his satisfaction score is defined as the minimal friendliness with any other guests.
 The satisfaction of the party itself is defined as the sum of satisfaction score  for all the guests.
To maximize satisfaction scores for the party,  who should Taro invite?
Write a program to calculate the maximal possible satisfaction score for the party.
Input
The first line of the input contains two integers,
n
and
m
(
1 \leq n \leq 100
,
0 \leq m \leq 100
).
The rabbits are numbered from
1
to
n
.
Each of the following
m
lines has three integers,
u
,
v
and
f
.
u
and
v
(
1 \leq u, v \leq n
,
u \neq v
,
1 \leq f \leq 1,000,000
) stands for  the rabbits' number, and
f
stands for their friendliness.
You may assume that the friendliness of  a pair of rabbits will be given at most once.
Output
Output the maximal possible satisfaction score of the party in a line.
Sample Input 1
3 3
1 2 3
2 3 1
3 1 2
Output for the Sample Input 1
6
Sample Input 2
2 1
1 2 5
Output for the Sample Input 2
10
Sample Input 3
1 0
Output for the Sample Input 3
0
Sample Input 4
4 5
1 2 4
1 3 3
2 3 7
2 4 5
3 4 6
Output for the Sample Input 4
16

Submitted solutions:

code_snippet: #include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int N, M, ST, gans, ans, hg1, ohg1;
int jiyou[120][120], val[200], oval[300];
bool used[1000];

int getans()
{
	int i, res = 0, nc = 0;
	for (i = ST; i <= N; ++i)
		if (used[i])
		{
			++nc;
			res += val[i];
		}
	if (nc < 2) return 0;
	return res;
}

void dfs(int x);

int main()
{
	int i, j, k, x, y, l;
	memset(jiyou, 0, sizeof(jiyou));
	scanf("%d%d", &N, &M);
	for (i = 0; i < M; ++i)
	{
		scanf("%d%d%d", &x, &y, &l);
		jiyou[x][y] = l;
		jiyou[y][x] = l;
	}
	for (i = 1; i < N; ++i)
	{
		ST = i;
		ans = 0;
		memset(used, 0, sizeof(used));
		memset(val, 127, sizeof(val));
		used[i] = true;
		dfs(i+1);
	}
	printf("%d\n", gans);
	return 0;
}

void dfs(int x)
{
	int i, haogandu = 10000000;
	if (x > N)
	{
		gans = max(gans, getans());
		return;
	}
	for (i = ST; i <= N; ++i)
		if (used[i])
			haogandu = min(haogandu, jiyou[x][i]);
	if (haogandu)
	{
		for (i = ST; i <= N; ++i)
			oval[i] = val[i];
		val[x] = haogandu;
		for (i = ST; i <= N; ++i)
			if (used[i])
			{
				val[i] = min(val[i], jiyou[x][i]);
				if (i > ST)
					val[ST] = min(val[ST], jiyou[i][ST]);
			}
		gans = max(gans, getans());
		used[x] = true;
		dfs(x+1);
		used[x] = false;
		for (i = ST; i <= N; ++i)
			val[i] = oval[i];
	}
	dfs(x+1);
}
accuracy: 0.4727272727272727
time_ms: 20
memory_kb: 3060
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;

template<class T>
bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0;}

bool is_end = false;
mt19937 engine(42);

void calc()
{
	int N, M; cin >> N >> M;
	vector<bool> has_friends(N, false);
	vector<vector<int>> weight(N, vector<int>(N, 0));
	for (int i = 0; i < M; ++i)
	{
		int a, b, f; cin >> a >> b >> f;
		a--, b--;
		has_friends[a] = has_friends[b] = true;
		weight[a][b] = weight[b][a] = f;
	}
	
	vector<int> perm;
	for (int i = 0; i < N; ++i)
	{
		if (has_friends[i]) {perm.emplace_back(i);}
	}
	
	int cnt = 0;
	int res = 0;
	while (cnt < 100000)
	{
		cnt++;
		shuffle(perm.begin(), perm.end(), engine);
		vector<int> cleak;
		
		for (auto v : perm)
		{
			bool flg = true;
			for (auto c : cleak)
			{
				flg &= (weight[v][c] > 0);
			}
			
			if (!flg) {continue;}
			cleak.emplace_back(v);
			
			if (cleak.size() == 1) {continue;}
			
			int tmp = 0;
			for (auto c : cleak)
			{
				int mn = 1e9;
				for (auto d : cleak)
				{
					if (c != d) {mn = min(mn, weight[c][d]);}
				}
				tmp += mn;
			}
			res = max(res, tmp);
		}
	}
	cout << res << endl;
	
	return;
}

int main()
{
	calc();
	
	return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 3472
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef __int128_t lll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef tuple<ll, ll, ll> tt;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vvb> vvvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef vector<pl> vp;
typedef vector<tt> vt;
typedef vector<string> vs;

const ll INF = 1000000010;
const ll INFL = INF * INF;
const double MYPI = acos(-1);
const ld epsilon = 1e-10;

#define ovl(a, b, c, d, e, ...) e
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define DEBUG(...) DEBUG_(#__VA_ARGS__, __VA_ARGS__)
#define REP1(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, l, r) for (int i = (l); i < (r); i++)
#define REP3(i, l, r, d) for (int i = (l); i < (r); i += (d))
#define REP(...) ovl(__VA_ARGS__, REP3, REP2, REP1)(__VA_ARGS__)
#define RREP1(i, n) for (int i = (n)-1; i >= 0; i--)
#define RREP2(i, l, r) for (int i = (r)-1; i >= (l); i--)
#define RREP3(i, l, r, d) for (int i = (r)-1; i >= (l); i -= (d))
#define RREP(...) ovl(__VA_ARGS__, RREP3, RREP2, RREP1)(__VA_ARGS__)
#define EACH1(e, a) for (auto &e : a)
#define EACH2(x, y, a) for (auto &[x, y] : a)
#define EACH3(x, y, z, a) for (auto &[x, y, z] : a)
#define EACH(...) ovl(__VA_ARGS__, EACH3, EACH2, EACH1)(__VA_ARGS__)
#define ALL(x) begin(x), end(x)
#define RALL(x) (x).rbegin(), (x).rend()
#define sz(x) (ll) x.size()
#define LB(a, x) (lower_bound(ALL(a), x) - a.begin())
#define UB(a, x) (upper_bound(ALL(a), x) - a.begin())
#define FLG(x, i) (((x) >> (i)) & 1)
#define CNTBIT(x) __builtin_popcountll(x)
#define TOPBIT(t) (t == 0 ? -1 : 63 - __builtin_clzll(t))
#define IN(x, a, b) ((a) <= (x) && (x) < (b))
#define int ll

template <class T, class... Ts>
void OUT(const T &a, const Ts &...b) {
    cout << a;
    (cout << ... << (cout << " ", b));
    cout << endl;
}

template <class T>
void DEBUG_(string_view name, const T &a) {
    cout << name << ": " << a << endl;
}

template <class T>
void DEBUG_(string_view name, const vector<T> &a) {
    cout << name << ": ";
    REP(i, sz(a)) cout << a[i] << " ";
    cout << endl;
}

template <class T, class U>
bool chmax(T &x, const U &y) {
    return x < y ? x = y, 1 : 0;
}
template <class T, class U>
bool chmin(T &x, const U &y) {
    return x > y ? x = y, 1 : 0;
}

template <class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
using maxheap = priority_queue<T>;

const vl dy = {1, 0, -1, 0, 1, -1, -1, 1};
const vl dx = {0, 1, 0, -1, 1, 1, -1, -1};

template <class T = ll>
struct Edge {
    ll from, to;
    T cost;
    ll idx;
    Edge(ll f, ll t, T c = 1, ll i = -1) : from(f), to(t), cost(c), idx(i) {}
    operator int() const { return to; }
};

template <class T = ll>
struct Graph {
    vector<vector<Edge<T>>> g;
    ll es;
    explicit Graph(ll n) : g(n), es(0) {}
    size_t size() const { return sz(g); }
    void add_directed_edge(ll from, ll to, T cost = 1) {
        g[from].eb(from, to, cost, es++);
    }
    void add_edge(ll from, ll to, T cost = 1) {
        g[from].eb(from, to, cost, es);
        g[to].eb(to, from, cost, es++);
    }
    inline vector<Edge<T>> &operator[](const int &k) { return g[k]; }
    inline const vector<Edge<T>> &operator[](const int &k) const {
        return g[k];
    }
};

//-----------------------------------------------------------------------

void solve() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    int N, M;
    cin >> N >> M;
    vvl Fs(N, vl(N, 0));
    set<vl> clique;
    ll ans = 0;
    REP(i, M) {
        int u, v, f;
        cin >> u >> v >> f;
        u--;
        v--;
        Fs[u][v] = f;
        Fs[v][u] = f;
        clique.insert({u, v});
        chmax(ans, 2 * f);
    }

    auto calcScore = [&](const vl &clique) -> ll {
        // DEBUG(clique);
        ll ans = 0;
        EACH(c1, clique) {
            ll ans2 = INFL;
            EACH(c2, clique) {
                if (c1 == c2) continue;
                chmin(ans2, Fs[c1][c2]);
            }
            ans += ans2;
        }
        // DEBUG(ans);
        return ans;
    };

    while (!clique.empty()) {
        // DEBUG(clique.size());
        set<vl> newClique;
        EACH(c, clique) {
            REP(nv, N) {
                if (find(ALL(c), nv) != c.end()) {
                    continue;
                }
                bool ok = true;
                EACH(v, c) {
                    if (Fs[v][nv] == 0) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) continue;
                vl newC = c;
                newC.insert(lower_bound(ALL(newC), nv), nv);
                chmax(ans, calcScore(newC));
                newClique.insert(newC);
            }
        }
        swap(clique, newClique);
    }

    cout << ans << endl;
}

signed main() {
    int T = 1;
    // cin >> T;

    while (T--) solve();

    // random_test();

    return 0;
}
accuracy: 1
time_ms: 1930
memory_kb: 74600
final_rank: 19

code_snippet: /**
 *    author:  otera
**/
#include<bits/stdc++.h>
using namespace std;

#define int long long

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using int128_t = __int128_t;
#define repa(i, n) for(int i = 0; i < n; ++ i)
#define repb(i, a, b) for(int i = a; i < b; ++ i)
#define repc(i, a, b, c) for(int i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define rep(...) overload4(__VA_ARGS__, repc, repb, repa)(__VA_ARGS__)
#define rep1a(i, n) for(int i = 0; i <= n; ++ i)
#define rep1b(i, a, b) for(int i = a; i <= b; ++ i)
#define rep1c(i, a, b, c) for(int i = a; i <= b; i += c)
#define rep1(...) overload4(__VA_ARGS__, rep1c, rep1b, rep1a)(__VA_ARGS__)
#define rev_repa(i, n) for(int i=n-1;i>=0;i--)
#define rev_repb(i, a, b) assert(a > b);for(int i=a;i>b;i--)
#define rev_rep(...) overload3(__VA_ARGS__, rev_repb, rev_repa)(__VA_ARGS__)
#define rev_rep1a(i, n) for(int i=n;i>=1;i--)
#define rev_rep1b(i, a, b) assert(a >= b);for(int i=a;i>=b;i--)
#define rev_rep1(...) overload3(__VA_ARGS__, rev_rep1b, rev_rep1a)(__VA_ARGS__)
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define Sort(a) sort(all(a))
#define Rev(a) reverse(all(a))
#define Uniq(a) sort(all(a));a.erase(unique(all(a)),end(a))
#define si(c) (int)(c).size()
inline ll popcnt(ull a){ return __builtin_popcountll(a); }
#define kth_bit(x, k) ((x>>k)&1)
#define unless(A) if(!(A))
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll intpow(ll a, ll b, ll m) {ll ans = 1; while(b){ if(b & 1) (ans *= a) %= m; (a *= a) %= m; b /= 2; } return ans; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type>name(__VA_ARGS__)
#define VEC(type,name,size) vector<type>name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
template <class T> using vc = vector<T>;
template <class T> using vvc = vector<vc<T>>;
template <class T> using vvvc = vector<vvc<T>>;
template <class T> using vvvvc = vector<vvvc<T>>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T, class U> using umap = unordered_map<T, U>;
template<class T> void scan(T& a){ cin >> a; }
template<class T> void scan(vector<T>& a){ for(auto&& i : a) scan(i); }
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){ scan(head); in(tail...); }
void print(){ cout << ' '; }
template<class T> void print(const T& a){ cout << a; }
template<class T> void print(const vector<T>& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ cout << ' '; print(*i); } }
int out(){ cout << '\n'; return 0; }
template<class T> int out(const T& t){ print(t); cout << '\n'; return 0; }
template<class Head, class... Tail> int out(const Head& head, const Tail&... tail){ print(head); cout << ' '; out(tail...); return 0; }
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#define dump(...) { print(#__VA_ARGS__); print(":"); out(__VA_ARGS__); }
#else
#define debug(...)
#define dump(...)
#endif

struct io_setup {
    io_setup(int precision = 20) {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout << fixed << setprecision(precision);
    }
} io_setup_ {};

const int inf = 1e9 + 7;

void solve() {
    INT(n, m);
    vvc<P> g(n);
    vvc<int> h(n, vc<int>(n, 0));
    rep(i, m) {
        INT(u, v, f); -- u, -- v;
        g[u].eb(v, f);
        g[v].eb(u, f);
        h[u][v] = h[v][u] = f; 
    }
    int ans = 0;
    auto dfs = [&](auto&&dfs, vc<int> used, int i) -> void {
        int ret = 0;
        bool ok = 1;
        int cnt = 0;
        for(int x = 0; x < i; ++ x) {
            if(used[x]) {
                ++ cnt;
                int now = inf;
                for(int y = 0; y < i; ++ y) {
                    if(y != x && used[y]) chmin(now, h[x][y]);
                }
                if(now == inf) ok = 0;
                ret += now;
            }
        }
        if(cnt >= 2 && !ok) return;
        if(ok) chmax(ans, ret);
        if(i == n) return;
        dfs(dfs, used, i + 1);
        ok = 1;
        if(cnt >= 1) {
            rep(x, i) {
                if(used[x]) {
                    if(h[x][i] == 0) ok = 0;
                }
            }
        }
        used[i] = 1;
        if(ok) dfs(dfs, used, i + 1);
        used[i] = 0;
        return;
    };
    vc<int> cur(n, 0);
    dfs(dfs, cur, 0);
    out(ans);
}

signed main() {
    int testcase = 1;
    // in(testcase);
    while(testcase--) solve();
    return 0;
}
accuracy: 1
time_ms: 240
memory_kb: 3644
final_rank: 12

code_snippet: #ifndef HIDDEN_IN_VISUAL_STUDIO // 折りたたみ用

// 警告の抑制
#define _CRT_SECURE_NO_WARNINGS

// ライブラリの読み込み
#include <bits/stdc++.h>
using namespace std;

// 型名の短縮
using ll = long long; // -2^63 ～ 2^63 = 9 * 10^18（int は -2^31 ～ 2^31 = 2 * 10^9）
using pii = pair<int, int>;	using pll = pair<ll, ll>;	using pil = pair<int, ll>;	using pli = pair<ll, int>;
using vi = vector<int>;		using vvi = vector<vi>;		using vvvi = vector<vvi>;
using vl = vector<ll>;		using vvl = vector<vl>;		using vvvl = vector<vvl>;
using vb = vector<bool>;	using vvb = vector<vb>;		using vvvb = vector<vvb>;
using vc = vector<char>;	using vvc = vector<vc>;		using vvvc = vector<vvc>;
using vd = vector<double>;	using vvd = vector<vd>;		using vvvd = vector<vvd>;
template <class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
using Graph = vvi;

// 定数の定義
const double PI = 3.14159265359;
const double DEG = PI / 180.; // θ [deg] = θ * DEG [rad]
const vi dx4 = { 1, 0, -1, 0 }; // 4 近傍（下，右，上，左）
const vi dy4 = { 0, 1, 0, -1 };
const vi dx8 = { 1, 1, 0, -1, -1, -1, 0, 1 }; // 8 近傍
const vi dy8 = { 0, 1, 1, 1, 0, -1, -1, -1 };
const int INF = 1001001001; const ll INFL = 2002002002002002002LL;
const double EPS = 1e-10; // 許容誤差に応じて調整

// 入出力高速化
struct fast_io { fast_io() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } fastIOtmp;

// 汎用マクロの定義
#define all(a) (a).begin(), (a).end()
#define sz(x) ((int)(x).size())
#define distance (int)distance
#define Yes(b) {cout << ((b) ? "Yes" : "No") << endl;}
#define rep(i, n) for(int i = 0, i##_len = int(n); i < i##_len; ++i) // 0 から n-1 まで昇順
#define repi(i, s, t) for(int i = int(s), i##_end = int(t); i <= i##_end; ++i) // s から t まで昇順
#define repir(i, s, t) for(int i = int(s), i##_end = int(t); i >= i##_end; --i) // s から t まで降順
#define repe(v, a) for(const auto& v : (a)) // a の全要素（変更不可能）
#define repea(v, a) for(auto& v : (a)) // a の全要素（変更可能）
#define repb(set, d) for(int set = 0; set < (1 << int(d)); ++set) // d ビット全探索（昇順）
#define repp(a) sort(all(a)); for(bool a##_perm = true; a##_perm; a##_perm = next_permutation(all(a))) // a の順列全て（昇順）
#define repit(it, a) for(auto it = (a).begin(); it != (a).end(); ++it) // イテレータを回す（昇順）
#define repitr(it, a) for(auto it = (a).rbegin(); it != (a).rend(); ++it) // イテレータを回す（降順）
#define smod(n, m) ((((n) % (m)) + (m)) % (m)) // 非負mod
#define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());} // 重複除去

// 汎用関数の定義
template <class T> inline ll pow(T n, int k) { ll v = 1; rep(i, k) v *= n; return v; }
template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; } // 最大値を更新（更新されたら true を返す）
template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; } // 最小値を更新（更新されたら true を返す）

// 演算子オーバーロード
template <class T, class U> inline istream& operator>> (istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template <class T, class U> inline ostream& operator<< (ostream& os, const pair<T, U>& p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template <class T, class U, class V> inline istream& operator>> (istream& is, tuple<T, U, V>& t) { is >> get<0>(t) >> get<1>(t) >> get<2>(t); return is; }
template <class T, class U, class V> inline ostream& operator<< (ostream& os, const tuple<T, U, V>& t) { os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")"; return os; }
template <class T, class U, class V, class W> inline istream& operator>> (istream& is, tuple<T, U, V, W>& t) { is >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t); return is; }
template <class T, class U, class V, class W> inline ostream& operator<< (ostream& os, const tuple<T, U, V, W>& t) { os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << "," << get<3>(t) << ")"; return os; }
template <class T> inline istream& operator>> (istream& is, vector<T>& v) { repea(x, v) is >> x; return is; }
template <class T> inline ostream& operator<< (ostream& os, const vector<T>& v) { repe(x, v) os << x << " "; return os; }
template <class T> inline ostream& operator<< (ostream& os, const list<T>& v) { repe(x, v) os << x << " "; return os; }
template <class T> inline ostream& operator<< (ostream& os, const set<T>& s) { repe(x, s) os << x << " "; return os; }
template <class T> inline ostream& operator<< (ostream& os, const set<T, greater<T>>& s) { repe(x, s) os << x << " "; return os; }
template <class T> inline ostream& operator<< (ostream& os, const unordered_set<T>& s) { repe(x, s) os << x << " "; return os; }
template <class T, class U> inline ostream& operator<< (ostream& os, const map<T, U>& m) { repe(p, m) os << p << " "; return os; }
template <class T, class U> inline ostream& operator<< (ostream& os, const unordered_map<T, U>& m) { repe(p, m) os << p << " "; return os; }
template <class T> inline ostream& operator<< (ostream& os, stack<T> s) { while (!s.empty()) { os << s.top() << " "; s.pop(); } return os; }
template <class T> inline ostream& operator<< (ostream& os, queue<T> q) { while (!q.empty()) { os << q.front() << " "; q.pop(); } return os; }
template <class T> inline ostream& operator<< (ostream& os, deque<T> q) { while (!q.empty()) { os << q.front() << " "; q.pop_front(); } return os; }
template <class T> inline ostream& operator<< (ostream& os, priority_queue<T> q) { while (!q.empty()) { os << q.top() << " "; q.pop(); } return os; }
template <class T> inline ostream& operator<< (ostream& os, priority_queue_rev<T> q) { while (!q.empty()) { os << q.top() << " "; q.pop(); } return os; }
template <class T> inline vector<T>& operator--(vector<T>& v) { rep(_i_, sz(v)) --v[_i_]; return v; }

// 手元環境（Visual Studio）
#ifdef _MSC_VER
#define popcount (int)__popcnt // 全ビット中の 1 の個数
#define popcountll (int)__popcnt64
inline int lsb(unsigned int n) { unsigned long i; _BitScanForward(&i, n); return i; } // 最下位ビットの位置（0-indexed）
inline int lsbll(unsigned long long n) { unsigned long i; _BitScanForward64(&i, n); return i; }
inline int msb(unsigned int n) { unsigned long i; _BitScanReverse(&i, n); return i; } // 最上位ビットの位置（0-indexed）
inline int msbll(unsigned long long n) { unsigned long i; _BitScanReverse64(&i, n); return i; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
#define dump(x) cout << "\033[1;36m" << (x) << "\033[0m" << endl;
#define dumps(x) cout << "\033[1;36m" << (x) << "\033[0m ";
#define dumpel(a) { int _i_ = -1; cout << "\033[1;36m"; repe(x, a) {cout << ++_i_ << ": " << x << endl;} cout << "\033[0m"; }
#define input_from_file(f) ifstream isTMP(f); cin.rdbuf(isTMP.rdbuf());
#define output_to_file(f) ofstream osTMP(f); cout.rdbuf(osTMP.rdbuf());
// 提出用（gcc）
#else
#define popcount (int)__builtin_popcount
#define popcountll (int)__builtin_popcountll
#define lsb __builtin_ctz
#define lsbll __builtin_ctzll
#define msb(n) (31 - __builtin_clz(n))
#define msbll(n) (63 - __builtin_clzll(n))
#define gcd __gcd
#define dump(x)
#define dumps(x)
#define dumpel(v)
#define input_from_file(f)
#define output_to_file(f)
#endif

#endif // 折りたたみ用


////-----------------AtCoder 専用-----------------
//#include <atcoder/all>
//using namespace atcoder;
//
//using mint = modint1000000007;
////using mint = modint998244353;
////using mint = modint; // mint::set_mod(m);
//
//template <class S, S(*op)(S, S), S(*e)()>ostream& operator<<(ostream& os, segtree<S, op, e> seg) { int n = seg.max_right(0, [](S x) {return true; }); rep(i, n) os << seg.get(i) << " "; return os; }
//template <class S, S(*op)(S, S), S(*e)(), class F, S(*mp)(F, S), F(*cp)(F, F), F(*id)()>ostream& operator<<(ostream& os, lazy_segtree<S, op, e, F, mp, cp, id> seg) { int n = seg.max_right(0, [](S x) {return true; }); rep(i, n) os << seg.get(i) << " "; return os; }
//istream& operator>> (istream& is, mint& x) { ll x_; is >> x_; x = x_; return is; }
//ostream& operator<< (ostream& os, const mint& x) { os << x.val(); return os; }
//using vm = vector<mint>;	using vvm = vector<vm>;		using vvvm = vector<vvm>;
////----------------------------------------------


//【コスト付きグラフの入力（コストは別）】O(|V| + |E|)
/*
* 始点 終点 コストの組からなる入力を受け取り，n 頂点 m 辺のグラフを構成する．
* 辺へのコストの割り当ては別で記録する．
*
* n : グラフの頂点の数
* m : グラフの辺の数
* g : ここにグラフを構築して返す
* c : 辺 (s, t) のコストを c[s][t] に格納する
* directed : 有向グラフなら true
* one_indexed : 入力が 1-indexed で与えられるなら true
*/
void read_graph(int n, int m, Graph& g, vector<unordered_map<int, ll>>& c,
	bool directed = false, bool one_indexed = true) {
	g = Graph(n);
	c = vector<unordered_map<int, ll>>(n);
	rep(i, m) {
		int a, b; ll x;
		cin >> a >> b >> x;

		if (one_indexed) { a--; b--; }

		g[a].push_back(b);
		c[a][b] = x;
		if (!directed) {
			g[b].push_back(a);
			c[b][a] = x;
		}
	}
}


//【クリークの列挙】O(2^√(2|E|) |V|)
/*
* 無向グラフ g の i 番目に見つけたクリークを cs[i] に頂点の列として列挙する．
* S ⊂ V がクリークであるとは，S の任意の 2 点を結ぶ辺が E に属することをいう．
*/
void enumerate_clique(const Graph& g, vvi& cs) {
	// 参考：https://www.slideshare.net/wata_orz/ss-12131479

	int n = sz(g);
	cs.clear();

	// 隣接行列 adj，各頂点の次数 deg，総次数 deg_sum，
	// 最小次数 deg_min，次数最小頂点の番号 i_min を得る．
	vvb adj(n, vb(n));
	vi deg(n);
	int deg_sum = 0, deg_min = INF, i_min = -1;
	rep(s, n) {
		deg[s] = sz(g[s]);
		deg_sum += deg[s];
		repe(t, g[s]) adj[s][t] = true;

		if (chmin(deg_min, deg[s])) i_min = s;
	}

	// 考慮すべき頂点のリスト
	vi v(n);
	iota(all(v), 0);

	// 素朴な方法で最大クリークを求める O(2^n n)
	function<void()> naive = [&]() {
		// 全ての部分集合 set について
		repb(set, n) {
			bool sum = 0;

			// n 頂点それぞれについて
			rep(i, n) {
				// set に選んでいないなら無関係
				if (!(set & (1 << i))) {
					continue;
				}

				// i 番目以降の頂点について
				repi(j, i + 1, n - 1) {
					// set に選んでいないなら無関係 
					if (!(set & (1 << j))) {
						continue;
					}

					// 辺 (v[i], v[j]) がなければクリークでない．
					if (!adj[v[i]][v[j]]) {
						goto NEXT_LOOP;
					}
				}
			}

			// クリークが見つかったので記録する．
			cs.push_back(vi());
			rep(i, n) {
				if (set & (1 << i)) {
					cs.rbegin()->push_back(v[i]);
				}
			}

		NEXT_LOOP:;
		}
	};

	int res = 1;
	while (n > 0) {
		// 辺に対して頂点が十分少ないなら素朴な方法で構わない．
		if (deg_min * deg_min >= deg_sum) {
			naive();
			return;
		}

		// 次数最小の頂点 v[i_min] の隣接点の番号の集合を得る．
		// 同時に v[i_min] に出入りする辺を削除したことにし，各頂点の次数 deg を更新する．
		vi ia;
		rep(i, n) {
			if (adj[v[i_min]][v[i]]) {
				ia.push_back(i);

				deg[v[i]]--;
			}
		}
		int d = sz(ia);

		// まず v[i_min] を含む最大クリークの大きさ res を求める．
		// v[i_min] の隣接点の部分集合 sub すべてについて
		repb(sub, d) {
			rep(i, d) {
				// sub に選んでいないなら無関係
				if (!(sub & (1 << i))) {
					continue;
				}

				repi(j, i + 1, d - 1) {
					// sub に選んでいないなら無関係
					if (!(sub & (1 << j))) {
						continue;
					}

					// sub がクリークでなければ何もしない．
					if (!adj[v[ia[i]]][v[ia[j]]]) {
						goto LOOP_END;
					}
				}
			}

			// sub がクリークなら v[i_min] と合わせてもクリークとなるので記録する．
			cs.push_back(vi({ v[i_min] }));
			rep(i, d) {
				if (sub & (1 << i)) {
					cs.rbegin()->push_back(v[ia[i]]);
				}
			}

		LOOP_END:;
		}

		// v[i_min] を含む最大クリークの大きさは求まったので，
		// 以降は v[i_min] を含まないクリークだけを考えれば良い．
		// 頂点 v[i_min] と v[n-1] を交換して n を減らすことで v[i_min] を除去する．
		swap(v[i_min], v[n - 1]);
		n--;

		// 総次数 deg_sum，最小次数 deg_min，次数最小頂点の番号 i_min を得る．
		deg_sum = 0;
		deg_min = INF;
		rep(i, n) {
			if (chmin(deg_min, deg[v[i]])) {
				i_min = i;
			}
			deg_sum += deg[v[i]];
		}
	}
}


int main() {
//	input_from_file("input.txt");
//	output_to_file("output.txt");

	int n, m;
	cin >> n >> m;

	Graph g;
	vector<unordered_map<int, ll>> c;
	read_graph(n, m, g, c);
	dumpel(g);
	dumpel(c);

	vvi cs;
	enumerate_clique(g, cs);
	dumpel(cs);

	ll res = 0;
	repe(cq, cs) {
		int k = sz(cq);
		if (k <= 1) continue;

		ll sc = 0;
		rep(i, k) {
			ll sat = INFL;
			rep(j, k) {
				if (i == j) continue;

				chmin(sat, c[cq[i]][cq[j]]);
			}
			sc += sat;
		}

		chmax(res, sc);
	}

	cout << res << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 4700
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n, vector<int>(n));
    set<vector<int>> st;
    for (int i = 0; i < m; ++i) {
        int u, v, f;
        cin >> u >> v >> f;
        --u, --v;
        if (u > v) swap(u, v);
        G[u][v] = G[v][u] = f;
        st.insert({u, v});
    }
    int ans = 0;
    while (!st.empty()) {
        set<vector<int>> nst;
        for (auto& v : st) {
            int val = 0;
            for (int i : v) {
                int m = 1e9;
                for (int j : v) {
                    if (i != j) m = min(m, G[i][j]);
                }
                val += m;
            }
            ans = max(ans, val);

            for (int k = 0; k < n; ++k) {
                bool ok = true;
                for (int i : v) {
                    if (G[i][k] == 0) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    auto u = v;
                    u.push_back(k);
                    sort(u.begin(), u.end());
                    nst.insert(u);
                }
            }
        }
        st.swap(nst);
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 4356
final_rank: 7

code_snippet: #include<bits/stdc++.h> 
using namespace std;
using ll=long long int;
//using Int=__int128;
#define ALL(A) A.begin(),A.end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
template<typename T> constexpr int bitUP(T x,int a){return (x>>a)&1;}
//→　↓　←　↑ 
int dh[4]={0,1,0,-1}, dw[4]={1,0,-1,0};
//右上から時計回り
//int dh[8]={-1,0,1,1,1,0,-1,-1}, dw[8]={1,1,1,0,-1,-1,-1,0};
long double EPS = 1e-6;
long double PI = acos(-1);
const ll INF=(1LL<<62);
const int MAX=(1<<30);
constexpr ll MOD=1000000000+7;
//constexpr ll MOD=998244353;


inline void bin101(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

using pii=pair<int,int>;
using pil=pair<int,ll>;
using pli=pair<ll,int>;
using pll=pair<ll,ll>;
using psi=pair<string,int>;
using pis=pair<int,string>;
using psl=pair<string,ll>;
using pls=pair<ll,string>;
using pss=pair<string,string>;

using Graph=vector<vector<int>>;

template<typename T >
struct edge {
	int to;
	T cost;
	edge()=default;
	edge(int to, T cost) : to(to), cost(cost) {}

};
template<typename T>
using WeightGraph=vector<vector<edge<T>>>;

template<typename T>
void CinGraph(int M,WeightGraph<T> &g,bool directed=false,bool index1=true){
    while(M--){
        int s,t;
        T cost;
        cin>>s>>t>>cost;
        if(index1) s--,t--;
        g[s].emplace_back(t,cost);
        if(not directed) g[t].emplace_back(s,cost);
    }
}

void CinGraph(int M,Graph &g,bool directed=false,bool index1=true){
    while(M--){
        int s,t;
        cin>>s>>t;
        if(index1) s--,t--;
        g[s].push_back(t);
        if(not directed) g[t].push_back(s);
    }
}


//0-indexed vector cin
template<typename T>
inline istream &operator>>(istream &is,vector<T> &v) {
    for(size_t i=0;i<v.size();i++) is>>v[i];
	return is;
}
 
//0-indexed vector cin
template<typename T>
inline istream &operator>>(istream &is,vector<vector<T>> &v) {
    for(size_t i=0;i<v.size();i++){
        is>>v[i];
    }
    return is;
}
//vector cout
template<typename T>
inline ostream &operator<<(ostream &os,const vector<T> &v) {
    for(size_t i=0;i<v.size();i++){
        if(i) os<<" ";
        os<<v[i];
    }
    return os;
}
//vector<vector> cout
template<typename T>
inline ostream &operator<<(ostream &os,const vector<vector<T>> &v) {
    for(size_t i=0;i<v.size();i++){
        os<<v[i];
        if(i+1!=v.size()) os<<"\n";
    }
    return os;
}

//Graph out
template<typename T>
inline ostream &operator<<(ostream &os,const Graph &g) {
    for(size_t i=0;i<g.size();i++){
        for(int to:g[i]){
            os<<i<<"->"<<to<<" ";
        }
        os<<endl;
    }
    return os;
}

//WeightGraph out
template<typename T>
inline ostream &operator<<(ostream &os,const WeightGraph<T> &g) {
    for(size_t i=0;i<g.size();i++){
        for(auto e:g[i]){
            os<<i<<"->"<<e.to<<"("<<e.cost<<") ";
        }
        os<<endl;
    }
    return os;
}


//要素数n 初期値x
template<typename T>
inline vector<T> vmake(size_t n,T x){
	return vector<T>(n,x);
}

//a,b,c,x data[a][b][c] 初期値x
template<typename... Args>
auto vmake(size_t n,Args... args){
	auto v=vmake(args...);
	return vector<decltype(v)>(n,move(v));
}
template<typename V,typename T>
void fill(V &v,const T value){
    v=value;
}

template<typename V,typename T>
void fill(vector<V> &vec,const T value){
    for(auto &v:vec) fill(v,value);
}

//pair cout
template<typename T, typename U>
inline ostream &operator<<(ostream &os,const pair<T,U> &p) {
	os<<p.first<<" "<<p.second;
	return os;
}
 
//pair cin
template<typename T, typename U>
inline istream &operator>>(istream &is,pair<T,U> &p) {
	is>>p.first>>p.second;
	return is;
}
 
//ソート
template<typename T>
inline void vsort(vector<T> &v){
    sort(v.begin(),v.end());
}
 
//逆順ソート
template<typename T>
inline void rvsort(vector<T> &v){
	sort(v.rbegin(),v.rend());
}

//1ビットの数を返す
inline int popcount(int x){
	return __builtin_popcount(x);
}
//1ビットの数を返す
inline int popcount(ll x){
	return __builtin_popcountll(x);
}
template<typename T>
inline void Compress(vector<T> &C){
    sort(C.begin(),C.end());
    C.erase(unique(C.begin(),C.end()),C.end());
}
template<typename T>
inline int lower_idx(const vector<T> &C,T value){
    return lower_bound(C.begin(),C.end(),value)-C.begin();
}
template<typename T>
inline int upper_idx(const vector<T> &C,T value){
    return upper_bound(C.begin(),C.end(),value)-C.begin();
}
//時計回りに90度回転
template<typename T>
inline void rotate90(vector<vector<T>> &C){
    vector<vector<T>> D(C[0].size(),vector<T>(C.size()));
    for(int h=0;h<C.size();h++){
        for(int w=0;w<C[h].size();w++){
            D[w][C.size()-1-h]=C[h][w];
        }
    }
    C=D;
}
//補グラフを返す
//i→iのような辺は加えない
Graph ComplementGraph(const Graph &g){
    size_t sz=g.size();
    bool used[sz][sz];
    fill(used[0],used[sz],false);
    for(size_t i=0;i<sz;i++){
        for(int to:g[i]){
            used[i][to]=true;
        }
    }
    Graph ret(sz);
    for(size_t i=0;i<sz;i++){
        for(size_t j=0;j<sz;j++){
            if(used[i][j]) continue;
            if(i==j) continue;
            ret[i].push_back(j);
        }
    }
    return ret;
}
//グラフの分解 secondはある頂点がどこに対応するか id[i]={2,3}のとき,頂点iはret[2][3]に対応
//無効グラフのみに対応
pair<vector<Graph>,vector<pair<int,int>>> GraphDecomposition(const Graph &g){
    vector<pair<int,int>> id(g.size(),pair<int,int>(-1,-1));
    vector<Graph> ret;
    vector<int> now;
    for(size_t i=0;i<g.size();i++){
        if(id[i].first!=-1) continue;
        id[i].first=ret.size();
        id[i].second=0;
        now.push_back(i);
        for(size_t j=0;j<now.size();j++){
            for(int to:g[now[j]]){
                if(id[to].first==-1){
                    id[to].first=ret.size();
                    id[to].second=now.size();
                    now.push_back(to);
                }
            }
        }
        Graph r(now.size());
        for(size_t j=0;j<now.size();j++){
            r[j]=g[now[j]];
            for(int &to:r[j]){
                to=id[to].second;
            }
        }
        ret.push_back(r);
        now.clear();
    }
    return make_pair(ret,id);
}
//0indexを想定
bool OutGrid(ll h,ll w,ll H,ll W){
    return (h>=H or w>=W or h<0 or w<0);
}

void NO(){
    cout<<"NO"<<"\n";
}
void YES(){
    cout<<"YES"<<"\n";
}
void No(){
    cout<<"No"<<"\n";
}
void Yes(){
    cout<<"Yes"<<"\n";
}
namespace overflow{
    template<typename T>
    T max(){
        return numeric_limits<T>::max();
    }
    template<typename T>
    T ADD(T a,T b){
        T res;
        return __builtin_add_overflow(a,b,&res)?max<T>():res;
    }
    template<typename T>
    T MUL(T a,T b){
        T res;
        return __builtin_mul_overflow(a,b,&res)?max<T>():res;
    }
};
using namespace overflow;
struct ModInt{
    using u64=uint_fast64_t;
    u64 a;
    constexpr ModInt() :a(0){}
    constexpr ModInt(ll x) :a((x>=0)?(x%MOD):(x%MOD+MOD) ) {}

    inline constexpr ModInt operator+(const ModInt rhs)const noexcept{
        return ModInt(*this)+=rhs;
    }
    inline constexpr ModInt operator-(const ModInt rhs)const noexcept{
        return ModInt(*this)-=rhs;
    }
    inline constexpr ModInt operator*(const ModInt rhs)const noexcept{
        return ModInt(*this)*=rhs;
    }
    inline constexpr ModInt operator/(const ModInt rhs)const noexcept{
        return ModInt(*this)/=rhs;
    }
    inline constexpr ModInt operator+(const ll rhs) const noexcept{
        return ModInt(*this)+=ModInt(rhs);
    }
    inline constexpr ModInt operator-(const ll rhs)const noexcept{
        return ModInt(*this)-=ModInt(rhs);
    }
    inline constexpr ModInt operator*(const ll rhs)const noexcept{
        return ModInt(*this)*=ModInt(rhs);
    }
    inline constexpr ModInt operator/(const ll rhs)const noexcept{
        return ModInt(*this)/=ModInt(rhs);
    }

    inline constexpr ModInt &operator+=(const ModInt rhs)noexcept{
        a+=rhs.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    inline constexpr ModInt &operator-=(const ModInt rhs)noexcept{
        if(rhs.a>a) a+=MOD;
        a-=rhs.a;
        return *this;
    }
    inline constexpr ModInt &operator*=(const ModInt rhs)noexcept{
        a=(a*rhs.a)%MOD;
        return *this;
    }
    inline constexpr ModInt &operator/=(ModInt rhs)noexcept{
        a=(a*rhs.inverse().a)%MOD;
        return *this;
    }
    inline constexpr ModInt &operator+=(const ll rhs)noexcept{
        return *this+=ModInt(rhs);
    }
    inline constexpr ModInt &operator-=(const ll rhs)noexcept{
        return *this-=ModInt(rhs);
    }
    inline constexpr ModInt &operator*=(const ll rhs)noexcept{
        return *this*=ModInt(rhs);
    }
    inline constexpr ModInt &operator/=(const ll rhs)noexcept{
        return *this/=ModInt(rhs);
    }

    inline constexpr ModInt operator=(const ll x)noexcept{
        a=(x>=0)?(x%MOD):(x%MOD+MOD);
        return *this;
    }

    inline constexpr bool operator==(const ModInt p)const noexcept{
        return a==p.a;
    }

    inline constexpr bool operator!=(const ModInt p)const noexcept{
        return a!=p.a;
    }

    inline constexpr ModInt pow(ll N) const noexcept{
        ModInt ans(1LL),p(a);
        while(N>0){
            if(bitUP(N,0)){
                ans*=p;
            }
            p*=p;
            N>>=1;
        }
        return ans;
    }
    inline constexpr ModInt inverse() const noexcept{
        return pow(MOD-2);
    }

};
inline constexpr ModInt operator+(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)+=b;
}
inline constexpr ModInt operator-(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)-=b;
}
inline constexpr ModInt operator*(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)*=b;
}
inline constexpr ModInt operator/(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)/=b;
}
//cout
inline ostream &operator<<(ostream &os,const ModInt &p) {
    return os<<p.a;
}

//cin
inline istream &operator>>(istream &is,ModInt &p) {
    ll t;
    is>>t;
    p=t;
    return is;
}

struct Binominal{
    vector<ModInt> fac,finv,inv; //fac[n]:n! finv:(n!)の逆元
    int sz;
    Binominal(int n=10) :sz(1){
        if(n<=0) n=10;
        init(n);
    }
    inline void init(int n){
        fac.resize(n+1,1);
        finv.resize(n+1,1);
        inv.resize(n+1,1);
        for(int i=sz+1;i<=n;i++){
            fac[i]=fac[i-1]*i;
            inv[i]=MOD-inv[MOD%i]*(MOD/i);
            finv[i]=finv[i-1]*inv[i];
        }
        sz=n;
    }
    //nCk(n,k<=N) をO(1)で求める
    inline ModInt com(int n,int k){
        if(n<k) return ModInt(0);
        if(n<0 || k<0) return ModInt(0);
        if(n>sz) init(n);
        return fac[n]*finv[k]*finv[n-k];
    }
    //nCk(k<=N) をO(k)　で求める 
    inline ModInt rcom(ll n,int k){
        if(n<0 || k<0 || n<k) return ModInt(0);
        if(k>sz) init(k);
        ModInt ret(1);
        for(int i=0;i<k;i++){
            ret*=n-i;
        }
        ret*=finv[k];
        return ret;
    }

    //重複組み合わせ n種類のものから重複を許してk個を選ぶ
    //〇がn個,|がk個
    inline ModInt h(int n,int k){
        return com(n+k-1,k);
    }
};
vector<int> Subset(int S,bool zero=false,bool full=false){
    vector<int> ret;
    int now=(S-1)&S;
    if(full and S){
        ret.push_back(S);
    }
    do{
        ret.push_back(now);
        now=(now-1)&S;
    }while(now!=0);
    if(zero){
        ret.push_back(0);
    }
    return ret;
}
template<typename T>
T SUM(const vector<T> &v,int s,int t){
    chmax(s,0);
    chmin(t,int(v.size())-1);
    if(s>t) return 0;
    if(s==0) return v[t];
    else return v[t]-v[s-1];
}
template<typename T>
void buildSUM(vector<T> &v){
    for(size_t i=1;i<v.size();i++){
        v[i]+=v[i-1];
    }
    return;
}
//最大クリークが14
//2^14*14^2 ->

bool S[100];
int N,M;
int ans=0;
vector<vector<int>> F;

void dfs(int idx){

    if(idx==N){
        vector<int> v;
        for(int i=0;i<N;i++){
            if(S[i]) v.push_back(i);
        }
        if(v.size()==1) return;
        int t=0;
        for(size_t i=0;i<v.size();i++){
            int min_v=MAX;
            for(size_t j=0;j<v.size();j++){
                if(i==j) continue;
                chmin(min_v,F[v[i]][v[j]]);
            }
            t+=min_v;
        }
        chmax(ans,t);
    }else{
        for(int i=idx;i<N;i++){
            bool ok=true;
            for(int j=0;j<i;j++){
                if(S[j] and F[i][j]==0) ok=false;
            }
            if(not ok) continue;
            S[i]=true;
            dfs(i+1);
            S[i]=false;
        }
        dfs(N);
    }
}

void solve(){
    cin>>N>>M;
    F=vmake(N,N,0);
    for(int i=0;i<M;i++){
        int s,t; cin>>s>>t;
        s--; t--;
        cin>>F[s][t];
        F[t][s]=F[s][t];
    }
    dfs(0);
    cout<<ans<<endl;
}

int main(){
    bin101();
    int T=1;
    //cin>>T;
    while(T--) solve();
}
accuracy: 1
time_ms: 30
memory_kb: 3508
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;

int N,M;
int flag[105][105];
vector<vector<int>>tmp;

void dfs(int n,vector<int>res) {
    if(n == N) {
        tmp.push_back(res);
        return;
    }
    bool ok = true;
    for(int i = 0; i < res.size(); i++) {
        if(flag[res[i]][n] == 0) {
            ok = false;
        }
    }
    dfs(n+1,res);
    if(ok) {
        res.push_back(n);
        dfs(n+1,res);
    }
}

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int u,v,c;
        cin >> u >> v >> c;
        u--;
        v--;
        flag[u][v] = c;
        flag[v][u] = c;
    }
    dfs(0,{});
    int ans = 0;
    for(int i = 0; i < tmp.size(); i++) {
        int res = 0;
        for(int j = 0; j < tmp[i].size(); j++) {
            int mi = 1001001001;
            for(int k = 0; k < tmp[i].size(); k++) {
                if(tmp[i][j] == tmp[i][k]) {
                    continue;
                }
                mi = min(mi,flag[tmp[i][j]][tmp[i][k]]);
            }
            res += mi;
        }
        if(tmp[i].size() == 1) {
            continue;
        }
        ans = max(ans,res);
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 4572
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define each(e, v) for(auto &e: v)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

struct io_setup{
    io_setup(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

set<vector<int>> s;
vector<vector<int>> es;
int N, M;
int ans = 0;

void dfs(vector<int> v){
    sort(all(v));
    if(s.count(v)) return;
    s.emplace(v);

    int n = sz(v), tmp = 0;

    if(n > 1){
        rep(i, n){
            int x = inf;
            rep(j, n){
                if(j == i) continue;
                chmin(x, es[v[i]][v[j]]);
            }
            tmp += x;
        }
    }

    chmax(ans, tmp);

    vector<int> deg(N, 0);

    rep(i, n){
        rep(j, N){
            if(es[v[i]][j] > 0) deg[j]++;
        }
    }

    rep(i, N){
        if(deg[i] == n){
            v.eb(i), dfs(v), v.pop_back();
        }
    }
}

int main(){
    cin >> N >> M;

    es.assign(N, vector<int>(N, 0));

    rep(i, M){
        int u, v, c; cin >> u >> v >> c; u--, v--;
        es[u][v] = c, es[v][u] = c;
    }

    rep(i, N) dfs({i});

    cout << ans << '\n';
}
accuracy: 1
time_ms: 30
memory_kb: 5152
final_rank: 8

code_snippet: #pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(x) cout<<x<<endl
#define printyes print("Yes")
#define printno print("No")
#define printYES print("YES")
#define printNO print("NO")
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI=acos(-1);
const double eps=1e-9;
template<class T,class E> ostream& operator<<(ostream& os,pair<T,E>& p){return os<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& os,const vector<T>& v){
  os<<"{";ll i;
  rep(i,v.size()){
    if(i)os<<",";
    os<<v[i];
  }
  os<<"}";
  return os;
}
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;}
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;}
#ifdef DEBUG
void debugg(){cerr<<endl;}
template<class T,class... Args>void debugg(const T& x,const Args&... args){cerr<<" "<<x;debugg(args...);}
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debugg(__VA_ARGS__)
#else
#define debug(...) (void(0))
#endif

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a,ll m=mod) {
  ll b=m,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+m)%m;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n,ll m=mod){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%m;
    a=a*a%m;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
ll N;
ll ans;
mat g;
map<vec,int> mp;
void solve(vec v){
  vsort(v);
  if(mp[v])return;
  mp[v]=1;
  debug(v);
  ll i,j,K=v.size();
  rep(i,N){
    rep(j,K){
      if(!g[i][v[j]])break;
    }
    if(j==K){
      v.emplace_back(i);
      solve(v);
      v.pop_back();
    }
  }
  if(K>1){
    ll res=0;
    rep(i,K){
      ll x=inf;
      rep(j,K){
        if(i==j)continue;
        chmin(x,g[v[i]][v[j]]);
      }
      res+=x;
    }
    chmax(ans,res);
  }
}
int main(){
  startupcpp();
  ll i,j,k,M;
  cin>>N>>M;
  g.resize(N,vec(N,0));
  while(M--){
    cin>>i>>j>>k;
    --i;--j;
    g[j][i]=g[i][j]=k;
  }
  solve(vec());
  print(ans);
}
accuracy: 1
time_ms: 20
memory_kb: 5872
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define var auto

const char newl = '\n';

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { bool c = a > b; if (c) a = b; return c; }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { bool c = a < b; if (c) a = b; return c; }

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<vector<ll>> mat(n, vector<ll>(n, 0));
  for (int i = 0; i < m; i++){
    int s, t, c;
    cin >> s >> t >> c;
    s--, t--;
    mat[s][t] = c;
    mat[t][s] = c;
  }
  vector<vector<int>> cliques{vector<int>{}};
  for (int i = 0; i < n; i++){
    var newqs = cliques;
    for (var&& clique : cliques){
      bool valid = true;
      for (var&& vert : clique){
        if (mat[vert][i] == 0){
          valid = false;
          break;
        }
      }
      if (!valid) continue;
      var newq = clique;
      newq.emplace_back(i);
      newqs.emplace_back(newq);
    }
    cliques = move(newqs);
  }
  ll res = 0;
  for (var&& clique : cliques){
    ll score = 0;
    for (var&& s : clique){
      ll mn = LLONG_MAX;
      for (var&& t : clique){
        if (s == t) continue;
        chmin(mn, mat[s][t]);
      }
      if (mn == LLONG_MAX) mn = 0;
      score += mn;
    }
    chmax(res, score);
  }
  cout << res << endl;
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 7276
final_rank: 10

code_snippet: #include<iostream>
#include<vector>
using namespace std;
int ans;
int N,M;
int d[100][100];
void dfs(int id,vector<int>A)
{
	if(id==N)
	{
		if(A.size()==1)return;
		int now=0;
		for(int a:A)
		{
			int t=1e9;
			for(int b:A)if(a!=b)t=min(t,d[a][b]);
			now+=t;
		}
		if(ans<now)ans=now;
		return;
	}
	dfs(id+1,A);
	for(int a:A)if(d[a][id]==0)return;
	A.push_back(id);
	dfs(id+1,A);
}
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int u,v,f;cin>>u>>v>>f;
		u--,v--;
		d[u][v]=d[v][u]=f;
	}
	vector<int>fst;
	dfs(0,fst);
	cout<<ans<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3220
final_rank: 1

code_snippet: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> M;
	vector<vector<int>>edge(N, vector<int>(N));
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> K;
		L--, R--;
		edge[L][R] = edge[R][L] = K;
	}
	vector<set<vector<int>>>vs(N + 1);
	for (int i = 0; i < N; i++) {
		vector<int>w(N);
		w[i] = 1;
		vs[1].insert(w);
	}
	int ans = 0;
	for (int i = 1; i < N; i++) {
		for (auto j : vs[i]) {
			for (int k = 0; k < N; k++) {
				if (j[k])continue;
				bool flag = true;
				for (int l = 0; l < N; l++) {
					if (j[l] && !edge[k][l])flag = false;
				}
				if (flag) {
					j[k] = 1;
					vs[i + 1].insert(j);
					j[k] = 0;
				}
			}
		}
	}
	for (int i = 2; i <= N; i++) {
		for (auto j : vs[i]) {
			vector<int>sum(N);
			for (int k = 0; k < N; k++) {
				if (!j[k])continue;
				sum[k] = MOD;
				for (int l = 0; l < N; l++) {
					if (!j[l])continue;
					if (k == l)continue;
					sum[k] = min(sum[k], edge[k][l]);
				}
			}
			ans = max(ans, accumulate(sum.begin(), sum.end(), 0));
		}
	}
	cout << ans << endl;
}
accuracy: 1
time_ms: 190
memory_kb: 10928
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
int INF = 10000000;
set<vector<bool>> st;
int dfs(vector<bool> &used, vector<vector<int>> &E){
  if (st.count(used)){
    return 0;
  }
  st.insert(used);
  int n = E.size();
  int ans = 0;
  for (int i = 0; i < n; i++){
    if (used[i]){
      int mn = INF;
      for (int j = 0; j < n; j++){
        if (used[j] && i != j){
          mn = min(mn, E[i][j]);
        }
      }
      if (mn != INF){
        ans += mn;
      }
    }
  }
  for (int i = 0; i < n; i++){
    bool ok = true;
    for (int j = 0; j < n; j++){
      if (used[j]){
        if (E[i][j] == 0 || i == j){
          ok = false;
        }
      }
    }
    if (ok){
      used[i] = true;
      ans = max(ans, dfs(used, E));
      used[i] = false;
    }
  }
  return ans;
}
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> E(n, vector<int>(n, 0));
  for (int i = 0; i < m; i++){
    int u, v, f;
    cin >> u >> v >> f;
    u--;
    v--;
    E[u][v] = f;
    E[v][u] = f;
  }
  vector<bool> used(n, false);
  cout << dfs(used, E) << endl;
}
accuracy: 1
time_ms: 430
memory_kb: 5024
final_rank: 16

code_snippet: #define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

//li chao tree by ei1333. It's public available.
// https://ei1333.github.io/luzhiled/snippets/structure/li-chao-tree.html
/*
template< typename T >
struct LiChaoTree {
    struct Line {
        T a, b;

        Line(T a, T b) : a(a), b(b) {}

        inline T get(T x) const { return a * x + b; }

        inline bool over(const Line& b, const T& x) const {
            return get(x) < b.get(x);
        }
    };

    vector< T > xs;
    vector< Line > seg;
    int sz;

    LiChaoTree(const vector< T >& x, T INF) : xs(x) {
        sz = 1;
        while (sz < xs.size()) sz <<= 1;
        while (xs.size() < sz) xs.push_back(xs.back() + 1);
        seg.assign(2 * sz - 1, Line(0, INF));
    }

    void update(Line& x, int k, int l, int r) {
        int mid = (l + r) >> 1;
        auto latte = x.over(seg[k], xs[l]), malta = x.over(seg[k], xs[mid]);
        if (malta) swap(seg[k], x);
        if (l + 1 >= r) return;
        else if (latte != malta) update(x, 2 * k + 1, l, mid);
        else update(x, 2 * k + 2, mid, r);
    }

    void update(T a, T b) { // ax+b
        Line l(a, b);
        update(l, 0, 0, sz);
    }

    T query(int k) { // xs[k]
        const T x = xs[k];
        k += sz - 1;
        T ret = seg[k].get(x);
        while (k > 0) {
            k = (k - 1) >> 1;
            ret = min(ret, seg[k].get(x));
        }
        return ret;
    }
};

#define int long long
void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> landmarks;
    vector<vector<int>> costs;
    REP(i, n) {
        vector<int> tmp;
        REP(q, m) {
            int b;
            cin >> b;
            b = xor128() % 10000000;
            tmp.push_back(b);
        }
        landmarks.push_back(tmp);
    }
    REP(i, n) {

        vector<int> tmp;
        {
            REP(q, m) {
                int b;
                cin >> b;
                b = xor128() % 100000000;
                tmp.push_back(b);
            }
        }
        costs.push_back(tmp);
    }
    vector<LiChaoTree<int>> yoko; // size should be m
    REP(i, n) {
        vector<int> hoge(m);
        REP(q, m) {
            hoge[q] = q;
        }
        LiChaoTree<int> now(hoge, 1e18);//size should be n
        yoko.push_back(now);
    }
    vector<vector<int>> dp = landmarks;
    for (int q = 0; q < m; ++q) {
        vector<int> hoge(n);
        REP(i, n) {
            hoge[i] = i;
        }
        LiChaoTree<int> now(hoge, 1e18);//size should be n

        for (int i = 0; i < n; ++i) {
            int now_min = costs[0][0] * (i + q);
            if (q < 0) {
                int geko = yoko[i].query(q);
                now_min = min(now_min, geko);
            }
            if (i != 0) {
                int geko = now.query(i);
                now_min = min(now_min, geko);
            }
            dp[i][q] = now_min;
            yoko[i].update(costs[i][q], landmarks[i][q] + dp[i][q] - q * costs[i][q]);
            now.update(costs[i][q], landmarks[i][q] + dp[i][q] - i * costs[i][q]);
        }
    }

    cout << dp[n - 1][m - 1] << endl;
}
*/

#define int ll
int used[200];
vector<int> kouho;
set<pair<int,int>> already;
int dist[200][200];
int n, m;

int dfs(int now,pair<int,int> bit) {
    if (now < 50) {
        bit.first += (1LL << now);
    }
    else {
        bit.second += (1LL << (now - 50));
    }
    if (already.count(bit)) {
        return 0;
    }
    used[now] = 1;
    kouho.push_back(now);
    already.insert(bit);
    for (int i = 0; i < n; ++i) {
        if (used[i]) continue;
        int ok = 1;
        REP(q, kouho.size()) {
            if (dist[kouho[q]][i] == 0) {
                ok = 0;
                break;
            }
        }
        if (ok == 0) continue;
        dfs(i, bit);
    }
    kouho.pop_back();
    used[now] = 0;
    return 0;
}

void solve() {
    cin >> n >> m;
    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    int ans = 0;
    REP(i, n) {
        ans = max(ans, dfs(i, pair<int, int>{0, 0}));
   }
    for (auto x : already) {
        vector<int> huku;
        for (int q = 0; q < 51; ++q) {
            if ((1LL << q) & x.first) {
                huku.push_back(q);
            }
            if ((1LL << q) & x.second) {
                huku.push_back(q + 50);
            }
        }
        if (huku.size() == 1) continue;
        int tmp = 0;
        REP(q, huku.size()) {
            int hoge = 1e9;
            REP(j, huku.size()) {
                if (q == j) continue;
                hoge = min(hoge, dist[huku[q]][huku[j]]);
            }
            tmp += hoge;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}
#undef int
int main() {
    init();
    solve();
}
accuracy: 1
time_ms: 10
memory_kb: 4252
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;

template<class T>
bool chmax(T& a, const T& b) {
    if (a < b) { a = b; return true; }
    return false;
}
template<class T>
bool chmin(T& a, const T& b) {
    if (b < a) { a = b; return true; }
    return false;
}

// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

// std::vector Declaration and Initialization
template<typename T>
vector<T> make_vector(size_t a, T x) { return vector<T>(a, x); }
template<typename T, typename U, typename... Ts>
auto make_vector(size_t a, U b, Ts... ts) {
    return vector<decltype(make_vector<T>(b,ts...))>(a, make_vector<T>(b, ts...));
}

// std::vector Input
template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto &e : v) is >> e;
    return is;
}

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::array Debug
template<typename T, size_t n>
ostream& operator<<(ostream& os, const array<T, n>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl

// Weighted edge
template<typename T>
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.src << "->" << e.to << ":" << e.cost << ")";
    }
};

using LL = long long;

#define fs first
#define sc second

const LL MOD = 1e9+7;

LL next_combination(LL mask) {
    LL x = mask & -mask, y = mask + x;
    return (((mask & ~y) / x) >> 1) | y;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, m; cin >> n >> m;
    auto G = make_v<int>(n, n);
    vector<int> deg(n);
    for (int i = 0; i < m; ++i) {
        int u, v, f;
        cin >> u >> v >> f;
        --u, --v;
        G[u][v] = G[v][u] = f;
        ++deg[u], ++deg[v];
    }

    int ans = 0;

    for (int k = 2; k <= 14; ++k) {
        vector<int> vs;
        for (int i = 0; i < n; ++i) {
            if (deg[i] >= k-1) {
                vs.emplace_back(i);
            }
        }

        if (k == 2) {
            for (int a : vs) {
                for (int b : vs) {
                    chmax(ans, 2*G[a][b]);
                }
            }
            continue;
        }
        if (k == 3) {
            for (int a : vs) {
                for (int b : vs) {
                    for (int c : vs) {
                        chmax(ans,
                                min(G[a][b],G[a][c]) +
                                min(G[b][a],G[b][c]) +
                                min(G[c][a],G[c][b])
                                );
                    }
                }
            }
            continue;
        }

        for (LL mask=(1LL<<k)-1; mask < 1LL<<vs.size(); mask=next_combination(mask))
        {
            assert(k <= vs.size());

            vector<int> score(n, numeric_limits<int>::max());

            for (int i = 0; i < vs.size(); ++i) if (mask >> i & 1) {
                for (int j = i+1; j < vs.size(); ++j) if (mask >> j & 1) {
                    chmin(score[vs[i]], G[vs[i]][vs[j]]);
                    chmin(score[vs[j]], G[vs[i]][vs[j]]);
                }
            }

            int total = 0;
            for (int i = 0; i < vs.size(); ++i) if (mask >> i & 1) {
                total += score[vs[i]];
            }
            chmax(ans, total);
        }
    }

    cout << ans << endl;

    return 0;
}
accuracy: 1
time_ms: 1720
memory_kb: 3264
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct Edge {
  int from, to, friendliness;
};
map<vector<bool>, int> mp;
ll dfs(int now, vector<bool> &sel, const vector<vector<Edge>> &g, const vvll &d, int n) {
  if(mp[sel] != 0) return mp[sel];
  ll res = 0;
  for(int i=0;i<n;++i) {
    if(!sel[i]) continue;
    ll val = LINF;
    for(int j=0;j<n;++j) {
      if(i == j || !sel[j]) continue;
      val = min(val, d[i][j]);
    }
    if(val == LINF) val = 0;
    res += val;
  }
  for(int i=0;i<(int)(g[now].size());++i) {
    int nxt = g[now][i].to;
    if(sel[nxt]) continue;
    bool ok = true;
    for(int j=0;j<n;++j) {
      if(j == nxt) continue;
      if(sel[j] && d[nxt][j] == 0) {
        ok = false;
        break;
      }
    }
    if(ok) {
      sel[nxt] = true;
      res = max(res, dfs(nxt, sel, g, d, n));
      sel[nxt] = false;
    }
  }
  return mp[sel] = res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<vector<Edge>> g(n);
  vvll d(n, vll(n, 0));
  for(int i=0;i<m;++i) {
    int u, v, f; cin >> u >> v >> f;
    u--; v--;
    g[u].push_back({u, v, f});
    g[v].push_back({v, u, f});
    d[u][v] = f;
    d[v][u] = f;
  }
  vector<bool> sel(n, false);
  ll ans = 0;
  for(int i=0;i<n;++i) {
    sel[i] = true;
    ans = max(ans, dfs(i, sel, g, d, n));
    sel[i] = false;
  }
  cout << ans << endl;
}
accuracy: 1
time_ms: 440
memory_kb: 5320
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=103,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    vector<vector<int>> A(N,vector<int>(N));
    
    for(int i=0;i<M;i++){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        A[a][b]=c;
        A[b][a]=c;
    }
    
    int ans=0;
    
    set<vector<int>> SE;
    
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(A[i][j]){
                ans=max(ans,A[i][j]*2);
                vector<int> use(N);
                use[i]=1;
                use[j]=1;
                SE.insert(use);
            }
        }
    }
    
    for(int q=2;q<15;q++){
        if(SE.empty()) break;
        
        set<vector<int>> ne;
        
        for(auto it=SE.begin();it!=SE.end();it++){
            for(int i=0;i<N;i++){
                if((*it)[i]) continue;
                bool ok=true;
                
                for(int j=0;j<N;j++){
                    if(i==j) continue;
                    if((*it)[j]&&A[i][j]==0){
                        ok=false;
                        break;
                    }
                }
                
                if(ok){
                    vector<int> S=*it;
                    S[i]=1;
                    int sum=0;
                    for(int j=0;j<N;j++){
                        if(S[j]==0) continue;
                        int mini=INF;
                        for(int k=0;k<N;k++){
                            if(S[k]==0) continue;
                            if(j==k) continue;
                            if(A[j][k]) mini=min(mini,A[j][k]);
                        }
                        sum+=mini;
                    }
                    
                    ans=max(ans,sum);
                    
                    ne.insert(S);
                }
            }
        }
        
        SE=ne;
    }
    
    cout<<ans<<endl;
}
accuracy: 1
time_ms: 200
memory_kb: 6480
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

template <typename T>
bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//const ll mod = 1000000007;
int N, M;
bitset<100> bits[100];
bitset<100> Zero;
int A[100][100];
int ans;
void dfs(bitset<100> now, bitset<100> can, int vertex) {
    /*
    cerr << "-----" << endl;
    cerr << now << endl;
    cerr << can << endl;
    cerr << vertex << endl;
    cerr << "-----" << endl;
    */
    if(now.count() >= 2) {
        int score = 0;
        for(int i = 0; i < N; i++) {
            if(!now[i]) continue;
            int nowscore = 1e9;
            for(int j = 0; j < N; j++) {
                if(!now[j]) continue;
                if(i == j) continue;
                chmin(nowscore, A[i][j]);
            }
            score += nowscore;
        }
        chmax(ans, score);
    }
    for(int i = vertex; i < N; i++) {
        if(!can[i]) {
            //cerr << "ng: " << vertex << " " << i << endl;
            continue;
        }
        auto sub = now;
        sub[i] = true;
        auto sub2 = can;
        sub2 &= bits[i];
        //cerr << "ok : " << vertex << " " << i << endl;
        dfs(sub, sub2, i + 1);
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        A[a][b] = c;
        A[b][a] = c;
        bits[a][b] = true;
        bits[b][a] = true;
    }
    bitset<100> One;
    for(int i = 0; i < N; i++) One[i] = true;
    dfs(Zero, One, 0);
    cout << ans << endl;
    /*
    for(int i = 0; i < N; i++) {
        cerr << bits[i] << endl;
    }
    */
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3256
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
const int MAX = 111;
int es[MAX][MAX]={};
signed main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int u,v,w;
    cin>>u>>v>>w;
    u--;v--;
    es[u][v]=es[v][u]=w;
  }

  int ans=0;
  vector<int> used(n,0);
  MFP([&](auto dfs,int v)->void{
        int res=0,cnt=0;
        for(int i=0;i<n;i++){
          if(!used[i]) continue;
          cnt++;
          int tmp=1e9;
          for(int j=0;j<n;j++)
            if(i!=j&&used[j]) chmin(tmp,es[i][j]);
          if(tmp==0) return;
          res+=tmp;
        }
        if(cnt>1) chmax(ans,res);

        if(v==n) return;

        used[v]=1;
        dfs(v+1);
        used[v]=0;
        dfs(v+1);
      })(0);

  cout<<ans<<endl;
  return 0;
}
accuracy: 1
time_ms: 390
memory_kb: 3132
final_rank: 14