func_code_string: #include <bits/stdc++.h>   using namespace std;   int _ = 1, tc = 1;   int dx[] = {0, 0, 1, -1};   int dy[] = {1, -1, 0, 0};   const int MAXN = 1e7 + 1;   int spf[MAXN];   int d, x, y;   void sieve() {     for (int i = 1; i < MAXN; i++) spf[i] = i;     for (int i = 4; i < MAXN; i += 2) spf[i] = 2;     for (int i = 3; i * i < MAXN; i += 2) {       if (spf[i] == i) {         for (int j = i * i; j < MAXN; j += i) {           if (spf[j] == j) spf[j] = i;         }       }     }   }   void extended_gcd(int a, int b) {     if (b == 0) {       d = a;       x = 1;       y = 0;     } else {       extended_gcd(b, a % b);       int temp = y;       y = x - y * (a / b);       x = temp;     }   }   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int lcm(int a, int b) { return a * (b / gcd(a, b)); }   int getmod(int x, int y, int mod) { return (((x - y) % mod) + mod) % mod; }   vector<string> split(string line, char dil) {     vector<string> tokens;     stringstream check1(line);     string intermediate;     while (getline(check1, intermediate, dil)) {       tokens.push_back(intermediate);     }     return tokens;   }   void read(vector<long long>& v) {     for (int i = 0; i < v.size(); i++) cin >> v[i];   }   long long calc(long long curr, long long cuts) {     int p2 = curr % cuts;     int p1 = cuts - p2;     long long w = curr / cuts;     long long val = p1 * w * w + p2 * (w + 1) * (w + 1);     return val;   }   void solve() {     int n, k;     cin >> n >> k;     vector<long long> v(n);     read(v);     priority_queue<pair<long long, pair<long long, long long> > > q;     long long time = 0;     for (int i = 0; i < n; i++) {       long long curr = v[i];       time += curr * curr;       q.push(make_pair(calc(curr, 1) - calc(curr, 2), make_pair(curr, 2)));     }     while (n < k) {       pair<long long, pair<long long, long long> > curr = q.top();       q.pop();       long long dec = curr.first;       long long past = curr.second.second;       long long org = curr.second.first;       q.push(make_pair(calc(org, past) - calc(org, past + 1),                        make_pair(org, past + 1)));       n++;       time -= dec;     }     cout << time << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     while (_--) {       solve();     }     return 0;   }   