Official Analysis (C++)

Implementation

Time Complexity: O(N2K)\mathcal{O}(N^2K)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!
using pi = pair<int, int>;
using pl = pair<ll, ll>;