criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <vector>
 
using namespace std;
 
bool check(vector <int> as, len, k) {
  for (const auto& a : as) {
    int num = (long double)a / (long double) len - 1;
    if (int(num) > k) return false;
  }
  return true;
}
 
int main() {
  int n, k; cin >> n >> k;
  vector <int> as(n,0);
  for (int i = 0; i < n; i++) cin >> as[i];
  int left = 0;
  int right = 1 << 9;
  while (left < right) {
    int center = (left + right) / 2;
    if (check(as, center, k)) left = center;
    else right = center;
  }
  cout << left << endl;
}

Compiler output:
a.cc:6:29: error: 'len' has not been declared
    6 | bool check(vector <int> as, len, k) {
      |                             ^~~
a.cc:6:34: error: 'k' has not been declared
    6 | bool check(vector <int> as, len, k) {
      |                                  ^
a.cc: In function 'bool check(std::vector<int>, int, int)':
a.cc:8:46: error: 'len' was not declared in this scope; did you mean 'mblen'?
    8 |     int num = (long double)a / (long double) len - 1;
      |                                              ^~~
      |                                              mblen
a.cc:9:20: error: 'k' was not declared in this scope
    9 |     if (int(num) > k) return false;
      |                    ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

bool check(vector <int> as, len, k) {
  for (const auto& a : as) {
    int num = (long double)a / (long double) len - 1
    if (int(num) > k) {
      return false;
    }
  }
  return true;
}

int main() {
  int n, k; cin >> n >> k;
  vector <int> as(n,0);
  for (int i = 0; i < n; i++) cin >> as[i];
  int left = 0;
  int right = 1 << 9;
  while (left < right) {
    int center = (left + right) / 2;
    if (check(as, center, k)) left = center;
    else right = center;
  }
  cout << left << endl;
}

Compiler output:
a.cc:6:29: error: 'len' has not been declared
    6 | bool check(vector <int> as, len, k) {
      |                             ^~~
a.cc:6:34: error: 'k' has not been declared
    6 | bool check(vector <int> as, len, k) {
      |                                  ^
a.cc: In function 'bool check(std::vector<int>, int, int)':
a.cc:8:46: error: 'len' was not declared in this scope; did you mean 'mblen'?
    8 |     int num = (long double)a / (long double) len - 1
      |                                              ^~~
      |                                              mblen
Language: C++

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

int main() {
  int N,K;cin>>N>>K;
  vector<double> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  sort(A.begin(),A.end());
  int count=0;
  int left=0;
  int right=n;
  while(left<right){
    int X=(left+right)/2;
    
    count=0;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: 'n' was not declared in this scope
   11 |   int right=n;
      |             ^
Language: C++

/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
using namespace std;

vector<int>v,
bool check (int m,int k)
{
    ll cnt = 0;
    for(int i=0;i<v.size();i++)
    {
        cnt += (v[i]+m-1)/m;
        cnt -= 1;
    }
    if (cnt > k)
        return 0;
    else
        return 1;
}

int main()
{
    int n,k,c = 0;
    cin >> n >> k;
    v.resize(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    
    int lo = 0, hi = 1e9,ans = -1;
    while(lo <= hi) {
        int mid = (lo + hi) / 2;
        if(check(mid,k)) {
            ans = mid;
            hi = mid - 1;
        }
        else {
            lo = mid + 1;
        }
    }
    cout << ans;
    return 0;
}


Compiler output:
a.cc:41:1: error: expected unqualified-id before 'bool'
   41 | bool check (int m,int k)
      | ^~~~
a.cc: In function 'int main()':
a.cc:68:12: error: 'check' was not declared in this scope
   68 |         if(check(mid,k)) {
      |            ^~~~~
Language: C++

/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
using namespace std;

vector<int>v,
bool check (int m,int k)
{
    ll cnt = 0;
    for(auto ele : v)
    {
        cnt += (ele+m-1)/m;
        cnt -= 1;
    }
    if (cnt > k)
        return 0;
    else
        return 1;
}

int main()
{
    int n,k,c = 0;
    cin >> n >> k;
    v.resize(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    
    int lo = 0, hi = 1e9,ans = -1;
    while(lo <= hi) {
        int mid = (lo + hi) / 2;
        if(check(mid,k)) {
            ans = mid;
            hi = mid - 1;
        }
        else {
            lo = mid + 1;
        }
    }
    cout << ans;
    return 0;
}


Compiler output:
a.cc:41:1: error: expected unqualified-id before 'bool'
   41 | bool check (int m,int k)
      | ^~~~
a.cc: In function 'int main()':
a.cc:68:12: error: 'check' was not declared in this scope
   68 |         if(check(mid,k)) {
      |            ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int N, K;
    vector<long> A;
    int a;

    cin >> N >> K;
    for(int i = 0; i < N; ++i){
        cin >> a;
        A.push_back(a);
    }

    long max = *max_element(A.begin(), A.end());
    long min = *min_element(A.begin(), A.end());
    long mid;
    int d, CountCut;
    while(max - min > 1){
        CountCut = 0;
        mid = (max + min) / 2;
        for(int i = 0; i < N; ++i){
            d = (A[i] mid - 1) / mid;
            if(d > 0) CountCut += d;
        }
        if (CountCut <= K) max = mid;
        else min = mid;
    }

    cout << max << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:22: error: expected ')' before 'mid'
   24 |             d = (A[i] mid - 1) / mid;
      |                 ~    ^~~~
      |                      )
Language: C++

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

int main(){
  int n,k,big,count=0;
  vector<int> vec(n);
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  big=vec.at(0);
  for(int i=0;i<n;i++){
    big=max(vec.at(i),big);
  }
  for(big;big<1;big--){
    for(int i=0;i<n;i++){
      for(int l=1;l<=k;l++){
        if(vec(i)/l>big){
          count++;
        }
      }
    }
    if(count>k){
      cout << big+1;
      return 0;
    }
  }
  return 0;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: no match for call to '(std::vector<int>) (int&)'
   18 |         if(vec(i)/l>big){
      |            ~~~^~~
Language: C++

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

int main(){
  int n,k,big,count=0;
  vector<int> vec(n);
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  big=vec.at(0);
  for(int i=0;i<n;i++){
    big=max(vec.at(i),big)
  }
  for(big;big<1;big--){
    for(int i=0;i<n;i++){
      for(int l=1;l<=k;l++){
        if(vec(i)/l>big){
          count++:
        }
      }
    }
    if(count>k){
      cout << big+1;
      return 0;
    }
  }
  return 0;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:13:27: error: expected ';' before '}' token
   13 |     big=max(vec.at(i),big)
      |                           ^
      |                           ;
   14 |   }
      |   ~                        
a.cc:18:15: error: no match for call to '(std::vector<int>) (int&)'
   18 |         if(vec(i)/l>big){
      |            ~~~^~~
a.cc:19:18: error: expected ';' before ':' token
   19 |           count++:
      |                  ^
      |                  ;
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int Search(vector<double> & d, const int k, double l, double r) {
	if (ceil(l) == ceil(r))
		return ceil(l);
	int i, a = 0;
	double p = (l + r) / 2.0;
	rep(i, d.size()) {
		a += ceil(d[i] / p) - 1;
	}
	if (a <= k)
		return Search(d, k, l, p);
	else
		return Search(d, k, p, r);
}

int main(void) {
	int num, i, k;
	cin >> num >> k;
	vector<double> d(num);
	rep(i, num)
		cin >> d[i];
	cout << Search(d, k, 0.0, 1e10) << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'int Search(std::vector<double>&, int, double, double)':
a.cc:19:13: error: 'ceil' was not declared in this scope
   19 |         if (ceil(l) == ceil(r))
      |             ^~~~
a.cc:24:22: error: 'ceil' was not declared in this scope
   24 |                 a += ceil(d[i] / p) - 1;
      |                      ^~~~
Language: C++

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

int main(){
	long long int n, k;
	cin>>n>>k;
	vector<long long int> v(n);
	long long int mn = 0, mx = 1e9;
	for (int i = 0; i<n; i++){
		cin>>v[i];
		if (v[i]>mx)
	}
	long long int M, cnt;
	while(mn+1<mx){
		cnt = 0;
		M = (mn+mx)/2;
		for(auto u : v)
			cnt+=((u+M-1)/M-1);
		if(cnt<=k) mx = M;
		else mn = M;
	}
	cout<<M;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: expected primary-expression before '}' token
   12 |         }
      |         ^
Language: C++

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

int main(){
	int n, k;
	cin>>n>>k;
	vector<int> v(n);
	int mn = 0, mx = 1e9;
	for (int i = 0; i<n; i++){
		cin>>v[i];
		if (v[i]>mx)
	}
	mx+=10;
	int M, cnt;
	while(mn+1<mx){
		cnt = 0;
		M = (mn+mx)/2;
		for(auto u : v)
			cnt+=(u-1)/M;
		if(cnt<=k) mx = M;
		else mn = M;
	}
	cout<<M;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: expected primary-expression before '}' token
   12 |         }
      |         ^
Language: C++

#include <iostream>
#define ll long long

using namespace std;

ll a[200002];

bool isValid(ll n,ll k,ll x){
  ll count=0;
  for(ll i=0;i<n;i++){
    if(a[i]>mid) count+=a[i]/x;
  }
  return (count<=k);
}

ll getAns(ll n, ll k){
  if(k==0){
    ll ans=a[0];
    for(ll i=1;i<n;i++) ans=max(ans,a[i]);
    return ans;
  }
  
  ll low=1;
  ll high=1000000002;
  ll mid=0;
  ll ans;
  
  while(low<=high){
 	mid = low + (high-low)/2;
    if(isValid(n,k,mid)){
      ans=mid;
      high=mid-1;
    }
    else low=mid+1;
  }
  return ans;
}
  

int main(){
  ll n,k;
  cin>>n>>k;
  
  for(ll i=0;i<n;i++) cin>>a[i];
  
  cout<<getAns(n,k)<<'\n';
}


Compiler output:
a.cc: In function 'bool isValid(long long int, long long int, long long int)':
a.cc:11:13: error: 'mid' was not declared in this scope
   11 |     if(a[i]>mid) count+=a[i]/x;
      |             ^~~
Language: C++

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >


ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<bool>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
	ll n, k;
	cin>>n>>k;
	vl a(n);
	for(ll i = 0; i < n; i++) cin>>a[i];
	ll low = 0, high = 0;
	for(auto i : a)
	    high = max(high, i);
	ll ans;
	while(low < high)
	{
	    ll mid = low + (high - low) / 2;
	    ll need = 0;
	    for(ll i = 0 ; i < n; i++)
	    {
	        need += (a[i] - 1)/ mid);
	    }
	    if(need <= k)
	    {
	        ans = mid;
	        high = mid - 1;
	    }
	    else
	        low = mid + 1;
	}
	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin>>t;
	while(t--)
	{
		solve();		
	}
	return 0;
}

ll mulmod(ll a, ll b)
{
	ll res = 0; 
	a = a % MOD;
	while(b > 0)
	{
		if (b % 2 == 1)
			res = (res + a) % MOD;
 
		a = (a * 2) % MOD; 
		b /= 2;
	} 
	return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a = (a * a) % MOD;
	}
	return res;
}

void getprime(vector<bool>&prime)
{
	prime[0] = false;
	prime[1] = false;
	
	for(ll i = 2; i * i <= MAX; i++)
	{
		if(prime[i])
		{
			for(ll j = i*i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
	fact[0] = 1;
	ifact[0] = 1;
	
	for(ll i = 1; i <= MAX; i++)
	{
		fact[i] = (fact[i-1] * i)%MOD;
		ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
	}
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
	ll res;
	res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
	return res;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:47:40: error: expected ';' before ')' token
   47 |                 need += (a[i] - 1)/ mid);
      |                                        ^
      |                                        ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll
 
int t, n, m, k, a[300010], q, l, r;
multiset<int> s;
 
int32_t main(){
INIT
cin>>n>>k;
for(int i=1; i<=n; i++){cin>>a[i]; s.insert(a[i]);}
int l=0, r=((int)1000000000), m=(l+r)/2;
 
 
while(l<r){
      //  cout<<l<<" "<<r<<" ";
    m=(l+r)/2;
    int k0=k;
    int sz=(m);
    for(int i=1; i<=n; i++){
            if(sz==0){
                k0-=(a[i]+1); continue
            }
        if( ((a[i])%sz)==0  ){
        k0-=max(( (int)( a[i]/sz) )-1, (int)0);}
        else{
            k0-=max(( (int)( a[i]/sz) ), (int)0);
        }
    }
 
    if(k0<0){
        l=m+1;
    }
    else{
        r=m;
    }
    m=(l+r)/2;
}
int k0=k;
int sz=m;
 
 
cout<<(m);
 
 
return 0;
}
 

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:30:39: error: expected ';' before '}' token
   30 |                 k0-=(a[i]+1); continue
      |                                       ^
      |                                       ;
   31 |             }
      |             ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define N 200010

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

    int n,k;
    cin>>n>>k;

    vector<ll> a(n);

    for(int i=0;i<n;i++)cin>>a[i];

    sort(a.begin(),a.end());

    int low=0;
    int high=a[n-1];
    int m=low+(high-low)/2;

    while(low!=m)
    {
        int cnt=0;
        for(int i=n-1;i>=0;i--)
        {
            int n=(a[i]-1)/m;
            if(n==0)break;
            cnt+=n;
            if(cnt>k)break;
        }

        if(cnt>k)low=m;
        else high=m;

        m=low+(high-low)/2;
    }

    cout<<high;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: 'll' was not declared in this scope
   13 |     vector<ll> a(n);
      |            ^~
a.cc:13:14: error: template argument 1 is invalid
   13 |     vector<ll> a(n);
      |              ^
a.cc:13:14: error: template argument 2 is invalid
a.cc:15:31: error: invalid types 'int[int]' for array subscript
   15 |     for(int i=0;i<n;i++)cin>>a[i];
      |                               ^
a.cc:17:12: error: request for member 'begin' in 'a', which is of non-class type 'int'
   17 |     sort(a.begin(),a.end());
      |            ^~~~~
a.cc:17:22: error: request for member 'end' in 'a', which is of non-class type 'int'
   17 |     sort(a.begin(),a.end());
      |                      ^~~
a.cc:20:15: error: invalid types 'int[int]' for array subscript
   20 |     int high=a[n-1];
      |               ^
a.cc:28:21: error: invalid types 'int[int]' for array subscript
   28 |             int n=(a[i]-1)/m;
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mod 1000000007
ll A[200009],k,a;
ll chk(ll x)
{
    ll cnt=0;
    for(ll c=0;c<a;c++)
    {
        if(A[c]>x)
        cnt=cnt+(ll)(A[c]/x);
    }
    return(cnt<=k);
}
ll binser(ll l,ll r)
{
    ll mid=(ll)((l+((r-l)/2));
    if(l>=r)
    {
        return r;
    }
    if(chk(mid))
    {
        return min(mid,binser(l,mid-1));
    }
    else
    {
        return binser(mid+1,r);
    }
}
int main()
{
    IOS;
    ll b,c,d,e,l=0,r,ans;
    cin>>a>>k;
    for(b=0;b<a;b++) cin>>A[b];
    sort(A,A+a);
    r=A[a-1];
    ans=binser(l,r);
    cout<<ans+1<<endl;
}

Compiler output:
a.cc: In function 'long long int binser(long long int, long long int)':
a.cc:21:30: error: expected ')' before ';' token
   21 |     ll mid=(ll)((l+((r-l)/2));
      |                ~             ^
      |                              )
Language: C

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

typedef struct mylist{
  int length;
  int count;
  double ans;
  mylist *next;
}mylist;

int main(void){
  int N,K;
  mylist *ptr;
  mylist *top;
  mylist *sec;
  cin>>N>>K;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin>>v.at(i);
  }
  sort(v.begin(),v.end(),greater<int>());
  vector<mylist> work(N);
  for(int i=0;i<N;i++){
    (work.at(i)).length=v.at(i);
    (work.at(i)).count=1;
    (work.at(i)).ans=v.at(i);
    if(i!=N-1){
      (work.at(i)).next=&(work.at(i+1));
    }
    else{
      (work.at(i)).next=NULL;
    }
  }
  top=&(work.at(0));
  for(int i=0;i<K;i++){
    top->count++;
    top->ans=top->length/((double)top->count);
    ptr=top->next;
    if(top->ans<ptr->ans){
      while(ptr->next!=NULL && top->ans>(ptr->next)->ans){
        ptr=ptr->next;
      }
      sec=top->next;
      top->next=ptr->next;
      ptr->next=top;
      top=sec;
    }
  }
  cout<<ceil(top->ans)<<endl;
}
        
    

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
bool isok(vector<int> &v,int mini,int k){
  int cnt=0;
  for(auto i:v){
    if(i>mini){
      if(i%mini==0)cnt+=i/mini;
      else cnt+=(i+mini)/mini;
    }
  }
  
  if(cnt<=k){
    return true;
  }else{
    return false;
  }
}
int main(){
  int n,k;
  cin>>n>>k;
  
  vector<int> v(n);
  
  for(auto &i:v){
    cin>>i;
  }
  
  int mini=1,maxi=1e9+100;
  
  while(min1<=max1){
    int mid=mini+(maxi-mini)/2;
    if(isok(v,mid,k)){
      maxi=mid;
    }else{
      mini=mid+1;
    }
  }
  
  cout<<mini<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: 'min1' was not declared in this scope; did you mean 'mini'?
   30 |   while(min1<=max1){
      |         ^~~~
      |         mini
a.cc:30:15: error: 'max1' was not declared in this scope; did you mean 'maxi'?
   30 |   while(min1<=max1){
      |               ^~~~
      |               maxi
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=2e5+10;
int n, k;  
int a[N];

bool check(int mid){
	LL res=0;
	for(int i=0;i<n;i++)
		res+=a[i]/x+(a[i]%x>0)-1;
	return res<=k;	
}
 
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];	
	sort(a, a+n);
	
	int l=0,r=1e9;
	while(l<r){
		int mid=l+r>>1;
		if(check(mid)) r=mid;
		else l=mid+1;	
	}
	
	cout<<l;

	return 0;
}


Compiler output:
a.cc: In function 'bool check(int)':
a.cc:13:27: error: 'x' was not declared in this scope
   13 |                 res+=a[i]/x+(a[i]%x>0)-1;
      |                           ^
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const int N=2e5+10;
int n, k;  
int a[N];

bool check(int mid){
	ll res=0;
	for(int i=0;i<n;i++)
		res+=ceil(a[i]*1.0/mid)-1;
	return res<=k;	
}
 
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];	
	sort(a, a+n);
	
	int l=0,r=1e9;
	while(l<r){
		int mid=l+r>>1;
		if(check(mid)) r=mid;
		else l=mid+1;	
	}
	
	cout<<l;

	return 0;
}


Compiler output:
a.cc: In function 'bool check(int)':
a.cc:10:9: error: 'll' was not declared in this scope
   10 |         ll res=0;
      |         ^~
a.cc:12:17: error: 'res' was not declared in this scope
   12 |                 res+=ceil(a[i]*1.0/mid)-1;
      |                 ^~~
a.cc:13:16: error: 'res' was not declared in this scope
   13 |         return res<=k;
      |                ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k;
long long a[200010];
int check(long long logg){
	int cnt=0;
	for(int i=0;i<n;i++)cnt+=a[i]/logg;
	return cnt;
}
int main(){
	cin>>n>>k;
	int mx=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	if(k==0){
		cout<<mx<<endl;
		return 0;
	}
	long double l=0,r=1e10;
	while(l<r-1){
		long double mid=(l+r)/2;
		if(check(mid)<=k)r=mid;
		else l=mid;
	}
	cout<<(int)(l+0.999)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:23: error: no matching function for call to 'max(int&, long long int&)'
   15 |                 mx=max(mx,a[i]);
      |                    ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:15:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   15 |                 mx=max(mx,a[i]);
      |                    ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:15:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |                 mx=max(mx,a[i]);
      |                    ~~~^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const int MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ng = 0,  ok = 1e9;
  while(abs(ng-ok)>1){
    int m = (ng+ok)/2;
    auto f = [&](int m){
      ll now = 0;
      rep(i,n) now += (a[i]-1)/m;
      return now <= k;
    };
    if(f(x)) ok = m;
    else ng = m;
  }
  cout << ok << endl;
      
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:10: error: 'x' was not declared in this scope
   35 |     if(f(x)) ok = m;
      |          ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const int MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ng = 0,  ok = 1e9;
  while(abs(ng-ok)>1){
    int m = (ng+ok)/2;
    auto f = [&](int m){
      ll now = 0;
      rep(i,n) now += (a[i]-1)/m;
      return now <= k;
    }
    if(f(x)) ok = m;
    else ng = m;
  }
  cout << ok << endl;
      
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: expected ',' or ';' before 'if'
   35 |     if(f(x)) ok = m;
      |     ^~
a.cc:36:5: error: 'else' without a previous 'if'
   36 |     else ng = m;
      |     ^~~~
Language: C++

#include<iostream>
#include <math.h>       /* pow */
#include <vector>     

using namespace std;
int main(){
    long N,K;
    cin >> N >> K;

    long *logs = new long[N];
    long all_len=0;
    for (long i = 0; i < N; ++i) {
        long buf;
        cin >> buf;
        logs[i] = buf;
        all_len += buf;
    }

    long *div_is = new long[N];
    long div_i_cnt = K;

    double unit = (double) all_len / (K+N);
    for(int i = 0; i < N; ++i)  {
        long div_i = ((long) (logs[i] / unit)) - 1;
        if (div_i < 0) div_i = 0;
        div_is[i] = div_i;
        div_i_cnt -= div_i;
    }

    vector<double> divd_len;
    for(int i = 0; i < N; ++i)  {
        long bo = div_is[i] + 1;
        double len = (double) logs[i] / bo;
        divd_len.push_back(len);
    }

    sort(divd_len.begin(), divd_len.end());

//    for (int i = 0; i < N; ++i) {
//        cout << divd_len[i] << endl;
//    }

    long ans = ceil(divd_len[N-div_i_cnt-1]);
    cout << ans << endl;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   37 |     sort(divd_len.begin(), divd_len.end());
      |     ^~~~
      |     sqrt
Language: C++

//
// Created by Sakurayama Kazuhiro on 2020/08/02.
//


#include<iostream>
#include <math.h>       /* pow */
#include <vector>       /* pow */

using namespace std;
int main(){
    long N,K;
    cin >> N >> K;

    long *logs = new long[N];
    long all_len=0;
    for (long i = 0; i < N; ++i) {
        long buf;
        cin >> buf;
        logs[i] = buf;
        all_len += buf;
    }

    long *div_is = new long[N];
    long div_i_cnt = K;

    double unit = (double) all_len / (K+N);
    for(int i = 0; i < N; ++i)  {
        long div_i = ((long) (logs[i] / unit)) - 1;
        if (div_i < 0) div_i = 0;
        div_is[i] = div_i;
        div_i_cnt -= div_i;
    }

    vector<double> divd_len;
    for(int i = 0; i < N; ++i)  {
        long bo = div_is[i] + 1;
        double len = (double) logs[i] / bo;
        divd_len.push_back(len);
    }

    sort(divd_len.begin(), divd_len.end());

    long ans = ceil(divd_len[N-div_i_cnt-1]);
    cout << ans << endl;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:42:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   42 |     sort(divd_len.begin(), divd_len.end());
      |     ^~~~
      |     sqrt
Language: C++

//
// Created by Sakurayama Kazuhiro on 2020/08/02.
//


#include<iostream>
#include <math.h>       /* pow */
#include <vector>       /* pow */

using namespace std;
int main(){
    long N,K;
    cin >> N >> K;

    long *logs = new long[N];
    long all_len=0;
    for (long i = 0; i < N; ++i) {
        long buf;
        cin >> buf;
        logs[i] = buf;
        all_len += buf;
    }

    long *div_is = new long[N];
    long div_i_cnt = K;

    double unit = (double) all_len / (K+N);
    for(int i = 0; i < N; ++i)  {
        long div_i = ((long) (logs[i] / unit)) - 1;
        if (div_i < 0) div_i = 0;
        div_is[i] = div_i;
        div_i_cnt -= div_i;
    }

    vector<double> divd_len;
    for(int i = 0; i < N; ++i)  {
        long bo = div_is[i] + 1;
        double len = (double) logs[i] / bo;
        divd_len.push_back(len);
    }

    sort(divd_len.begin(), divd_len.end());

    for (int i = 0; i < N; ++i) {
        cout << divd_len[i] << endl;
    }

    long ans = ceil(divd_len[N-div_i_cnt-1]);
    cout << ans << endl;


//    cout << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:42:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   42 |     sort(divd_len.begin(), divd_len.end());
      |     ^~~~
      |     sqrt
Language: C++

#include<iostream>
#include<vector>
using namespace std;

int main(){
    // 入力
    long long n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> A[i];
    // 最大値をx以下にできるか
    auto check = [&](long long x) -> bool {
        long long cnt = 0;
        for (int i = 0; i < n; i++) cnt += (A[i] - 1) / x;
        return cnt <= k;
    };
    // めぐる式二分探索
    long long ok = 1e9, ng = 0;
    while(ok - ng > 1){
        long long mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    // 出力
    cout << ok << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:40: error: 'A' was not declared in this scope
    9 |     for (int i = 0; i < n; i++) cin >> A[i];
      |                                        ^
a.cc: In lambda function:
a.cc:13:45: error: 'A' was not declared in this scope
   13 |         for (int i = 0; i < n; i++) cnt += (A[i] - 1) / x;
      |                                             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
   int t=1;
  // cin>>t;
   while(t--)
   {
    
    int n, k; cin >> n >> k;
    vector<int64_t> a(n); 
    int left = 0, right = 0;
    for(auto i = 0; i < n; i++) { cin >> a[i]; right = max(right, a[i]); }
    if(k == 0) { cout << right << endl; return 0; }
    while(right > left) {
        int mid = (left + right) / 2, cnt = 0;
        for (auto i = 0; i < n; i++) cnt += (a[i] + mid - 1) / mid - 1;
       
        if(cnt > k) left = mid + 1;
        else right = mid;
    }
    cout << right << endl;
    return 0;
}
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:13:59: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&)'
   13 |     for(auto i = 0; i < n; i++) { cin >> a[i]; right = max(right, a[i]); }
      |                                                        ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:13:59: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   13 |     for(auto i = 0; i < n; i++) { cin >> a[i]; right = max(right, a[i]); }
      |                                                        ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:13:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |     for(auto i = 0; i < n; i++) { cin >> a[i]; right = max(right, a[i]); }
      |                                                        ~~~^~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll mo=1000000007;
bool ok(ll arr[],ll mid,ll k){
    ll sum=0;
    for(ll i=0;i<n;i++){
            sum+=arr[i]/mid;
        }
    return (sum<=k);    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t)
    {
        ll n,k;
        cin>>n>>k;
        ll arr[n];
        ll ma=INT_MIN;
        for(ll i=0;i<n;i++){
            cin>>arr[i];
            ma=max(ma,arr[i]);
        }

        ll l=0;
        ll r=ma;
        ll mid;
        while(l<=r){
            mid=l+(r-l)/2;
            if(ok(arr,mid,k)){
                r=mid;
            }
            else{
                l=mid;
            }
        }

        t--;
    }
}

Compiler output:
a.cc: In function 'bool ok(ll*, ll, ll)':
a.cc:7:18: error: 'n' was not declared in this scope
    7 |     for(ll i=0;i<n;i++){
      |                  ^
Language: C

//#include <bits/stdc++.h>
#include<iostream>
#include<string.h>
#include<stdio.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
ll in(ll a,ll mod)
{
    ll d,x,y;
    gcd(a,mod,d,x,y);
    return d==1?(x+mod)%mod:-1;
}
int n;
ll k,a[200005];
ll l=0,r=1e9+7,mid;
int ok(ll x)
{
    int c=0;
    for(int i=0;i<n;i++)
    {
        c+=a[i]/x-1;
        if(a[i]%x!=0)
            c++;
    }
    if(k>=c)
        return 1;
    else
        return 0;
}
int main()
{
    read(n);
    read(k);
    for(int i=0;i<n;i++)
        read(a[i]);

    while(l<=r)
    {
        mid=(l+r)/2;
        if(ok(mid))
            r=mid-1;
        else
            l=mid+1;
    }
    cout<<l<<endl;
    return 0;

}


Compiler output:
main.c:2:9: fatal error: iostream: No such file or directory
    2 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include "bits/stdc++.h"
using namespace std;


int main() {
	int N, K;
	cin >> N >> K;
	vector<long double>A(N);
	long double maxsize = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		maxsize = max(A[i], maxsize);
	}

	long double l = eps;
	long double r = maxsize; 
	long double eps = 0.00001;
	while (r - l > eps) {
		long double x = (l + r) / 2;
		int count = 0;
		for (int i = 0; i < N; ++i) {
			count += floor((A[i] / x));
		}
		if (count > K) {
			l = x;
		}
		else {
			r = x;
		}
	}
	cout << ceil(r-eps) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: 'eps' was not declared in this scope
   15 |         long double l = eps;
      |                         ^~~
Language: C++

#include "bits/stdc++.h"
using namespace std;


int main() {
	int N, K;
	cin >> N >> K;
	vector<double>A(N);
	double maxsize = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		maxsize = max(A[i], maxsize);
	}

	double l = 0.000001;
	double r = maxsize;
	for (int n = 0; n < 100; ++n) {
		double x = (l + r) / 2;
		int count = 0;
		for (int i = 0; i < N; ++i) {
			count += floor((A[i] / x));
		}
		if (count > K) {
			l = x;
		}
		else {
			r = x;
		}
	}
	cout << ceil(right) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:21: error: no matching function for call to 'ceil(std::ios_base& (&)(std::ios_base&))'
   30 |         cout << ceil(right) << endl;
      |                 ~~~~^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:114,
                 from a.cc:1:
/usr/include/c++/14/cmath:174:5: note: candidate: 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::ceil(_Tp)'
  174 |     ceil(_Tp __x)
      |     ^~~~
/usr/include/c++/14/cmath:174:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/cmath: In substitution of 'template<class _Tp> constexpr typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::ceil(_Tp) [with _Tp = std::ios_base& (*)(std::ios_base&)]':
a.cc:30:14:   required from here
   30 |         cout << ceil(right) << endl;
      |                 ~~~~^~~~~~~
/usr/include/c++/14/cmath:174:5: error: no type named '__type' in 'struct __gnu_cxx::__enable_if<false, double>'
  174 |     ceil(_Tp __x)
      |     ^~~~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:192:1: note: candidate: 'double ceil(double)'
  192 | __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
      | ^~~~~~~~~~~
In file included from /usr/include/math.h:275,
                 from /usr/include/c++/14/cmath:47:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:192:1: note:   no known conversion for argument 1 from 'std::ios_base&(std::ios_base&)' to 'double'
  192 | __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
      | ^
/usr/include/c++/14/cmath:166:3: note: candidate: 'constexpr long double std::ceil(long double)'
  166 |   ceil(long double __x)
      |   ^~~~
/usr/include/c++/14/cmath:166:20: note:   no known conversion for argument 1 from 'std::ios_base&(std::ios_base&)' to 'long double'
  166 |   ceil(long double __x)
      |        ~~~~~~~~~~~~^~~
/usr/include/c++/14/cmath:162:3: note: candidate: 'constexpr float std::ceil(float)'
  162 |   ceil(float __x)
      |   ^~~~
/usr/include/c++/14/cmath:162:14: note:   no known conversion for argument 1 from 'std::ios_base&(std::ios_base&)' to 'float'
  162 |   ceil(float __x)
      |        ~~~~~~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool solve(ll mid, ll n, ll a[], ll k){
  bool ok=0;
  for(int i=0; i<n; ++i){
    ll req=a[i]/mid;
    k-=req;
  }
  if(k>=0) return false;
  else return true;
}
int main()
{
  ll n, k; cin >> n >> k;
  ll a[n];
  for(int i=0; i<n; ++i) cin >> a[i];
  sort(a,a+n);
  if(k==0){
    cout << a[n-1] << "\n";
    return 0;
  }
  ll lo=0, hi=1e12;
  int count=0;
  while(lo<hi){
    ++count;
    if(count==100) break;
    if(mid==0) continue;
    ll mid=lo+(hi-lo)/2;
    //cout << lo << " " << hi << " " << mid << " " << solve(mid,n,a,k) << "\n";
    if(solve(mid,n,a,k)) lo=mid+1;
    else hi=mid;
  }
  cout << lo << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:8: error: 'mid' was not declared in this scope
   28 |     if(mid==0) continue;
      |        ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

bool chk(int l,int a[],int n,int k)
{
    int sum=0;
    for(int i=0;i<n;i++)
    {
        sum+=(a[i]-1)/l);
    }
    if(sum<=k)
        return true;
    else
        return false;
}

void solve()
{
    int n,k;cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=1,u=*max_element(a,a+n);
    int ans=u;
    while(l<=u)
    {
        int mid=(l+u)/2;
        if(chk(mid,a,n,k))
        {
            ans=mid;
            u=mid-1;
        }
        else
            l=mid+1;
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Compiler output:
a.cc: In function 'bool chk(long long int, long long int*, long long int, long long int)':
a.cc:31:24: error: expected ';' before ')' token
   31 |         sum+=(a[i]-1)/l);
      |                        ^
      |                        ;
Language: C++

#include <bits/stdc++.h>
using namespace std; 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long ll; 
const ll MOD = 1000000007;

int main()  
{ 
    FAST_INP;
    int t,n,k;
    cin >> n >> k;
    vector<ll> a(n);
    ll l=0,r=0;
    for(int i=0;i<n;i++) {
    	cin >> a[i];
    	r=max(r,a[i]);
	}
    while(l!=r){
    	int m = l+(r-l)/2;
    	ll kk=0;
		for(int i=0; i<n;i++){
			kk+=(a[i]-1)/m;
		}
    	if(res<=k) r=m;
    	else l=m+1;
	}
	cout << l << endl;
    return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:24:12: error: 'res' was not declared in this scope
   24 |         if(res<=k) r=m;
      |            ^~~
Language: Java

import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class ProblemE {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			int[] a = new int[n];
			// left必ず達成できない、right必ず達成できる
			int left = 0, right = IntStream.range(0, n).map(i -> a[i] = scanner.nextInt()).max().getAsInt();
			while (right - left > 0) {
				int mid = (left + right) / 2;
				if ((left == mid) || (right == mid)) {
					break;
				}
				if (ok(n, k, a, mid)) {
					right = mid;
				} else {
					left = mid;
				}
			}
			System.out.println(right);
		}
	}

	/**
	 * 目標値をk回まで切ることで達成できるかを計算する
	 * 
	 * @param n      丸太の数
	 * @param k      切る回数の上限
	 * @param a      丸太の長さの配列
	 * @param target 目標値
	 * @return 目標値をk回のカットで達成できるか
	 */
	private static boolean ok(int n, int k, int[] a, int target) {
		return IntStream.range(0, n).map(i -> (int) (((long) a[i] + target - 1) / target - 1)).sum() <= k;
	}
}


Compiler output:
Main.java:7: error: class ProblemE is public, should be declared in a file named ProblemE.java
public class ProblemE {
       ^
1 error
Language: C++

#pragma warning(disable : 4996)
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef tuple<ll,ll,ll> tl3;
// https://atcoder.jp/contests/abc174/tasks/abc174_e
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,k;
    cin >> n >> k;
    vector<ll> v(n);
    for(int i = 0;i<n;i++){
        cin >> v[i];
    }
    ll l = 0;
    ll h = 1e9+1;
    ll ans = 0;
    while(l <= h){
        ll mid = (l+h)/2;
        if(mid < 1){
            ans = 1;
            break;
        }
        ll temp = 0;
        for(auto k : v){
            temp += ((k+mid-1)/mid) - 1;
        if(temp <= k){
            ans = mid;
            h = mid - 1;
        }
        else
            l = mid+1;
    }
    cout << ans;

    return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:2: error: expected '}' at end of input
   43 | }
      |  ^
a.cc:11:11: note: to match this '{'
   11 | int main(){
      |           ^
Language: C++

/*
                                             ::                     ::
                                             ':                     :
                                              :.                    :
                                           ;' ::                   ::  '
                                          .'  ';                   ;'  '.
                                         ::    :;                 ;:    ::
                                         ;      :;.             ,;:     ::
                                         :;      :;:           ,;"      ::
                                         ::.      ':;  ..,.;  ;:'     ,.;:
                                          "'"...   '::,::::: ;:   .;.;""'
                                              '"""....;:::::;,;.;"""
                                          .:::.....'"':::::::'",...;::::;.
                                         ;:' '""'"";.,;:::::;.'""""""  ':;
                                        ::'         ;::;:::;::..         :;
                                       ::         ,;:::::::::::;:..       ::
                                       ;'     ,;;:;::::::::::::::;";..    ':.
                                      ::     ;:"  ::::::"""'::::::  ":     ::
                                       :.    ::   ::::::;  :::::::   :     ;
                                        ;    ::   :::::::  :::::::   :    ;
                                         '   ::   ::::::....:::::'  ,:   '
                                          '  ::    :::::::::::::"   ::
                                             ::     ':::::::::"'    ::
                                             ':       """""""'      ::
                                              ::                   ;:
                                              ':;                 ;:"


                                                     P_r_A_d_Y
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void cs(int &x)
{
  cout << "Case #" << x << ": ";
}
bool cmp(int a, int b)
{
  return a > b;
}
int32_t main()
{
  fastIO;
  // int t;cin>>t;
  // int x=1;
  // while(t--)
  // {
  int n; cin >> n >> k;
  vector<int>v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  int l = 0, h = *max_element(v.begin(), v.end());
  while (l < r)
  {
    int mid = l + (h - l) / 2;
    int p = 0;
    for (auto i : v)
      p += (i - 1) / 2;

    if (p >= k)
      h = mid;
    else
      l = mid + 1;
  }

  cout << l << endl;




  //}
  return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:54:22: error: 'k' was not declared in this scope
   54 |   int n; cin >> n >> k;
      |                      ^
a.cc:59:14: error: 'r' was not declared in this scope
   59 |   while (l < r)
      |              ^