Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main(){
  int n, k;
  vector<int> next(n);
  rep(i, n){
    int num;
    cin >> num; num--;
    vec[i] = num;
  }
  vector<int> point(n);
  rep(i, n) cin >> point[i];
  ll biggest = -1000000001;
  rep(i, n){
    vector<int> tmp;
    tmp.push_back(i);
    int c = i;
    ll sbiggest = -1000000001;
    ll sum = 0;
    sum += point[c];
    sbiggest = max(sbiggest, sum);
    while(next[c] != i){
      c = next[c];
      sum += point[c];
      sbiggest = max(sbiggest, sum);
      tmp.push_back(c);
    }
    if(sum <= 0) biggest = max(biggest, sbiggest);
    else{
      ll b = -1000000001;
      ll csum = 0;
      rep(j, k%tmp.size()){
        csum += point[tmp[j]];
        b = max(b, csum);
      }
      biggest = max(biggest, b+sum*k/tmp.size());
    }
  }
  cout << biggest << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'vec' was not declared in this scope
   24 |     vec[i] = num;
      |     ^~~
a.cc:51:20: error: no matching function for call to 'max(ll&, long long unsigned int)'
   51 |       biggest = max(biggest, b+sum*k/tmp.size());
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:51:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   51 |       biggest = max(biggest, b+sum*k/tmp.size());
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:51:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |       biggest = max(biggest, b+sum*k/tmp.size());
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~