Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll ans=1;
  ll n,k;
  cin >> n >> k;
  vl a(n);
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  ll z=sqrt(sum);
  vl p(100000);
  ll j=0;
  FOR(i,1,z+1){
    if(sum%i==0){
      p[j]=i;
      j++;
    }
  }
  j--;
  ll x;
  if(sum==z*z){
    p.resize(2*j+1);
    FOR(i,j+1,2*j+1){
      p[i]=sum/p[2*j-i];
    }
    x=2*j+1;
  }
  else{
    p.resize(2*j+2);
    FOR(i,j+1,2*j+2){
      p[i]=sum/p[2*j+1-i];
    }
    x=2*j+2;
  }
  vl b(n);
  vl c(n);
  rep(i,x){
    ll MIN=INF;
    rep(j,n){
      b[j]=a[j]%p[i];
    }
    sort(b.begin(),b.end());
    rep(j,n){
      c[j]=(p[i]-b[j])%p[i];
    }
    vl sumb(n);
    vl sumc(n);
    sumb[0]=b[0];
    sumc[n-1]=c[n-1];
    rep(i,n-1){
      sumb[i+1]=sumb[i]+b[i+1];
      sumc[n-2-i]=sumc[n-1-i]+c[n-2-i];
    }
    rep(j,n-1){
      MIN=min(min,max(sumb[j],sumc[j+1]));
    }
    if(MIN<=k){
      ans=p[i];
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:14: error: no matching function for call to 'min(<unresolved overloaded function type>, const long long int&)'
   71 |       MIN=min(min,max(sumb[j],sumc[j+1]));
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = long long int]'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:20: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const long long int&'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |         ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:71:14: note:   couldn't deduce template parameter '_Tp'
   71 |       MIN=min(min,max(sumb[j],sumc[j+1]));
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~