Language: C++

#include <bits/stdc++.h>

using namespace std;

struct P {
  int value, cuts, iV;
};

struct comp
{
    bool operator()(const P &r, const P &l)
    {
        return r.value < l.value;
    }
};


P newP(int v, int c, int i) {
  P p;
  p.value = v;
  p.cuts = c;
  p.iV = i;
  return p;
}

typedef long long ll;
const int mxn = 2e5;
int x,n, k;
set<P,comp> a;


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

  cin >> n >> k;
  int temp;
  for (int i = 0;i<n;i++) {
    cin >> temp;
    a.insert(newP(temp, 0, temp));
  }

  while (k>0) {
    auto it = a.rend();
    int v = (*it).i - ((*it).i/(*it).c)*((*it).c-1);
    P p = newP(v, (*it).c+1,(*it).i);
    s.erase((*it));
    s.insert(p);
  }
  auto it = a.rend();
  cout << (*it).v <<endl;





}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:19: error: 'const struct P' has no member named 'i'; did you mean 'iV'?
   45 |     int v = (*it).i - ((*it).i/(*it).c)*((*it).c-1);
      |                   ^
      |                   iV
a.cc:45:30: error: 'const struct P' has no member named 'i'; did you mean 'iV'?
   45 |     int v = (*it).i - ((*it).i/(*it).c)*((*it).c-1);
      |                              ^
      |                              iV
a.cc:45:38: error: 'const struct P' has no member named 'c'
   45 |     int v = (*it).i - ((*it).i/(*it).c)*((*it).c-1);
      |                                      ^
a.cc:45:48: error: 'const struct P' has no member named 'c'
   45 |     int v = (*it).i - ((*it).i/(*it).c)*((*it).c-1);
      |                                                ^
a.cc:46:25: error: 'const struct P' has no member named 'c'
   46 |     P p = newP(v, (*it).c+1,(*it).i);
      |                         ^
a.cc:46:35: error: 'const struct P' has no member named 'i'; did you mean 'iV'?
   46 |     P p = newP(v, (*it).c+1,(*it).i);
      |                                   ^
      |                                   iV
a.cc:47:5: error: 's' was not declared in this scope
   47 |     s.erase((*it));
      |     ^
a.cc:51:17: error: 'const struct P' has no member named 'v'
   51 |   cout << (*it).v <<endl;
      |                 ^
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(_Const_Link_type) [with _Key = P; _Val = P; _KeyOfValue = std::_Identity<P>; _Compare = comp; _Alloc = std::allocator<P>; _Const_Link_type = const std::_Rb_tree_node<P>*]':
/usr/include/c++/14/bits/stl_tree.h:2116:47:   required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = P; _Val = P; _KeyOfValue = std::_Identity<P>; _Compare = comp; _Alloc = std::allocator<P>; key_type = P]'
 2116 |           __comp = _M_impl._M_key_compare(__k, _S_key(__x));
      |                                                ~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:2169:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = P; _Key = P; _Val = P; _KeyOfValue = std::_Identity<P>; _Compare = comp; _Alloc = std::allocator<P>]'
 2169 |         = _M_get_insert_unique_pos(_KeyOfValue()(__v));
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:523:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = P; _Compare = comp; _Alloc = std::allocator<P>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<P, P, std::_Identity<P>, comp, std::allocator<P> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<P>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<P>, P>::rebind<P>; typename _Alloc::value_type = P; value_type = P]'
  523 |           _M_t._M_insert_unique(std::move(__x));
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:40:13:   required from here
   40 |     a.insert(newP(temp, 0, temp));
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:768:15: error: static assertion failed: comparison object must be invocable as const
  768 |               is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:768:15: note: 'std::is_invocable_v<const comp&, const P&, const P&>' evaluates to false