#include using namespace std; typedef long long ll; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b>N>>K; vector A,B; for(int i=0;i>x; if(x<=K) A.push_back(x); else B.push_back(x); } sort(all(A)); reverse(all(A)); ll ans=0; for(int i=0;i