Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int minc(ll a[],ll n)
{
  int index = 0;
    int min = array[index];

    for (int i = 1; i < n; i++){
        if (array[i] <= min){
        min = array[i];
        index = i;
        }
    }
        return index;
}
int main(){
 ll n,k;cin>>n>>k;
  ll a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  k=k%n;
  ll min=*min_element(a,n);
  for(int i=0;i<k;i++)
  {
    min = a[min-1];
  }
  cout<<min<<endl;
}


Compiler output:
a.cc: In function 'int minc(ll*, ll)':
a.cc:7:20: error: missing template arguments before '[' token
    7 |     int min = array[index];
      |                    ^
a.cc:10:18: error: expected unqualified-id before '[' token
   10 |         if (array[i] <= min){
      |                  ^
a.cc:11:20: error: missing template arguments before '[' token
   11 |         min = array[i];
      |                    ^
a.cc: In function 'int main()':
a.cc:22:22: error: no matching function for call to 'min_element(ll [n], ll&)'
   22 |   ll min=*min_element(a,n);
      |           ~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5577:12: note: candidate: 'template<class _FIter> constexpr _FIter std::min_element(_FIter, _FIter)'
 5577 |     inline min_element(_ForwardIterator __first, _ForwardIterator __last)
      |            ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5577:12: note:   template argument deduction/substitution failed:
a.cc:22:22: note:   deduced conflicting types for parameter '_FIter' ('long long int*' and 'long long int')
   22 |   ll min=*min_element(a,n);
      |           ~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_algo.h:5602:5: note: candidate: 'template<class _FIter, class _Compare> constexpr _FIter std::min_element(_FIter, _FIter, _Compare)'
 5602 |     min_element(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5602:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:516:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Compare)'
  516 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Compare __comp);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:516:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:520:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::min_element(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator)'
  520 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:520:1: note:   candidate expects 3 arguments, 2 provided