Language: C++

#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ppb pop_back()
#define fi first
#define se second
#define pi pair<int, int>
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define Y "Yes"
#define N "No"
using namespace std;

ll n, k, sum, x[200001], mi, ma;

bool p(ll a) {
	ll cnt = 0;
	REP(i, 0, n) {
		if (x[i] > a) {
			ll y = (x[i] - a - 1) / a + 1;
			if (y == 0) cnt++;
			else cnt += y;
		}
	}
	return cnt <= k;
}

ll search(ll a, ll b) {
	if (b - a <= 1) {
		if (p(a)) return a;
		return b;
	}
	ll m = (a + b) / 2;
	if (p(m)) return search(a, m);
	return search(m, b);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	freopen("in.txt", "r", stdin);

	cin >> n >> k >> x[0];
	mi = x[0];
	ma = x[0];
	REP(i, 1, n) {
		cin >> x[i];
		mi = min(mi, x[i]);
		ma = max(ma, x[i]);
	}
	if (k == 0) cout << ma;
	else cout << search(mi / k, ma);
}#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ppb pop_back()
#define fi first
#define se second
#define pi pair<int, int>
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define Y "Yes"
#define N "No"
using namespace std;

ll n, k, sum, x[200001], mi, ma;

bool p(ll a) {
	ll cnt = 0;
	REP(i, 0, n) {
		if (x[i] > a) {
			ll y = (x[i] - a - 1) / a + 1;
			if (y == 0) cnt++;
			else cnt += y;
		}
	}
	return cnt <= k;
}

ll search(ll a, ll b) {
	if (b - a <= 1) {
		if (p(a)) return a;
		return b;
	}
	ll m = (a + b) / 2;
	if (p(m)) return search(a, m);
	return search(m, b);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	//freopen("in.txt", "r", stdin);

	cin >> n >> k >> x[0];
	mi = x[0];
	ma = x[0];
	REP(i, 1, n) {
		cin >> x[i];
		mi = min(mi, x[i]);
		ma = max(ma, x[i]);
	}
	if (k == 0) cout << ma;
	else cout << search(mi / k, ma);
}

Compiler output:
a.cc:56:2: error: stray '#' in program
   56 | }#include <bits/stdc++.h>
      |  ^
a.cc:56:3: error: 'include' does not name a type
   56 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:71:4: error: redefinition of 'long long int n'
   71 | ll n, k, sum, x[200001], mi, ma;
      |    ^
a.cc:16:4: note: 'long long int n' previously declared here
   16 | ll n, k, sum, x[200001], mi, ma;
      |    ^
a.cc:71:7: error: redefinition of 'long long int k'
   71 | ll n, k, sum, x[200001], mi, ma;
      |       ^
a.cc:16:7: note: 'long long int k' previously declared here
   16 | ll n, k, sum, x[200001], mi, ma;
      |       ^
a.cc:71:10: error: redefinition of 'long long int sum'
   71 | ll n, k, sum, x[200001], mi, ma;
      |          ^~~
a.cc:16:10: note: 'long long int sum' previously declared here
   16 | ll n, k, sum, x[200001], mi, ma;
      |          ^~~
a.cc:71:15: error: redefinition of 'long long int x [200001]'
   71 | ll n, k, sum, x[200001], mi, ma;
      |               ^
a.cc:16:15: note: 'long long int x [200001]' previously declared here
   16 | ll n, k, sum, x[200001], mi, ma;
      |               ^
a.cc:71:26: error: redefinition of 'long long int mi'
   71 | ll n, k, sum, x[200001], mi, ma;
      |                          ^~
a.cc:16:26: note: 'long long int mi' previously declared here
   16 | ll n, k, sum, x[200001], mi, ma;
      |                          ^~
a.cc:71:30: error: redefinition of 'long long int ma'
   71 | ll n, k, sum, x[200001], mi, ma;
      |                              ^~
a.cc:16:30: note: 'long long int ma' previously declared here
   16 | ll n, k, sum, x[200001], mi, ma;
      |                              ^~
a.cc:73:6: error: redefinition of 'bool p(long long int)'
   73 | bool p(ll a) {
      |      ^
a.cc:18:6: note: 'bool p(long long int)' previously defined here
   18 | bool p(ll a) {
      |      ^
a.cc:85:4: error: redefinition of 'long long int search(long long int, long long int)'
   85 | ll search(ll a, ll b) {
      |    ^~~~~~
a.cc:30:4: note: 'long long int search(long long int, long long int)' previously defined here
   30 | ll search(ll a, ll b) {
      |    ^~~~~~
a.cc:95:5: error: redefinition of 'int main()'
   95 | int main() {
      |     ^~~~
a.cc:40:5: note: 'int main()' previously defined here
   40 | int main() {
      |     ^~~~