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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> town(N);

    for (int i = 0; i < N; i++) {
        cin >> town.at(i);
    }

    int now = 0;
    vector<int> check(N);
    check.at(0) = 1;
    int num = N;

    for (int i = 0; i < N; i++) {
        now = town.at(now) - 1;
        if (check.at(now) == 0) {
            check.at(now) = 1;
        }
        else if (check.at(now) == 1) {
            num = i + 1;
            break;
        }    
    }

    int ans = K % num;

    now = 0;
    for (int i = 0; i < ans; i++) {
        now = town.at(now) - 1;
    }

    cout << now + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> N >> K;
      |     ^~~
a.cc:4:5: error: 'vector' was not declared in this scope
    4 |     vector<int> town(N);
      |     ^~~~~~
a.cc:4:12: error: expected primary-expression before 'int'
    4 |     vector<int> town(N);
      |            ^~~
a.cc:7:16: error: 'town' was not declared in this scope
    7 |         cin >> town.at(i);
      |                ^~~~
a.cc:11:12: error: expected primary-expression before 'int'
   11 |     vector<int> check(N);
      |            ^~~
a.cc:12:5: error: 'check' was not declared in this scope
   12 |     check.at(0) = 1;
      |     ^~~~~
a.cc:16:15: error: 'town' was not declared in this scope
   16 |         now = town.at(now) - 1;
      |               ^~~~
a.cc:30:15: error: 'town' was not declared in this scope
   30 |         now = town.at(now) - 1;
      |               ^~~~
a.cc:33:5: error: 'cout' was not declared in this scope
   33 |     cout << now + 1 << endl;
      |     ^~~~
a.cc:33:24: error: 'endl' was not declared in this scope
   33 |     cout << now + 1 << endl;
      |                        ^~~~
Language: C++

int main(){
    int n;
    long long k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    map<int, int> arrive;
    vector<bool> checked(n,false);
    vector<int> route;
    int now=0;
    int count=0;
    while(count<k){
        if(checked[now]==true) break;
        checked[now]=true;
        arrive[now]=count;
        route.push_back(now);
        count++;
        now=a[now];
    }
    if(count==k) cout<<now<<endl;
    else{
        int cicle=count-arrive[now];
        cout<<route[arrive[now]+(k-count)%cicle]+1<<endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin>>n>>k;
      |     ^~~
a.cc:5:5: error: 'vector' was not declared in this scope
    5 |     vector<int> a(n);
      |     ^~~~~~
a.cc:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> a(n);
      |            ^~~
a.cc:7:14: error: 'a' was not declared in this scope
    7 |         cin>>a[i];
      |              ^
a.cc:10:5: error: 'map' was not declared in this scope
   10 |     map<int, int> arrive;
      |     ^~~
a.cc:10:9: error: expected primary-expression before 'int'
   10 |     map<int, int> arrive;
      |         ^~~
a.cc:11:12: error: expected primary-expression before 'bool'
   11 |     vector<bool> checked(n,false);
      |            ^~~~
a.cc:12:12: error: expected primary-expression before 'int'
   12 |     vector<int> route;
      |            ^~~
a.cc:16:12: error: 'checked' was not declared in this scope
   16 |         if(checked[now]==true) break;
      |            ^~~~~~~
a.cc:17:9: error: 'checked' was not declared in this scope
   17 |         checked[now]=true;
      |         ^~~~~~~
a.cc:18:9: error: 'arrive' was not declared in this scope
   18 |         arrive[now]=count;
      |         ^~~~~~
a.cc:19:9: error: 'route' was not declared in this scope
   19 |         route.push_back(now);
      |         ^~~~~
a.cc:21:13: error: 'a' was not declared in this scope
   21 |         now=a[now];
      |             ^
a.cc:23:18: error: 'cout' was not declared in this scope; did you mean 'count'?
   23 |     if(count==k) cout<<now<<endl;
      |                  ^~~~
      |                  count
a.cc:23:29: error: 'endl' was not declared in this scope
   23 |     if(count==k) cout<<now<<endl;
      |                             ^~~~
a.cc:25:25: error: 'arrive' was not declared in this scope
   25 |         int cicle=count-arrive[now];
      |                         ^~~~~~
a.cc:26:9: error: 'cout' was not declared in this scope; did you mean 'count'?
   26 |         cout<<route[arrive[now]+(k-count)%cicle]+1<<endl;
      |         ^~~~
      |         count
a.cc:26:15: error: 'route' was not declared in this scope
   26 |         cout<<route[arrive[now]+(k-count)%cicle]+1<<endl;
      |               ^~~~~
a.cc:26:53: error: 'endl' was not declared in this scope
   26 |         cout<<route[arrive[now]+(k-count)%cicle]+1<<endl;
      |                                                     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using namespace boost::multiprecision;
int main()
{
  uint128_t n=0;
  uint128_t k=0;
  cin>>n;
  cin>>k;
  vector<int> v;
  for(int i=0;i<n;i++)
  {
  int temp;
  cin>>temp;
  v.push_back(temp);
   }

 // k=k%n;
  int i=0;
  int t;
 // k++;
  while(k--)
  {
    t=arr[i];
    i=t-1;
   // k++;
  }
  cout<<arr[t-1]<<endl;
  //return 0;
}

Compiler output:
a.cc:3:17: error: 'boost' has not been declared
    3 | using namespace boost::multiprecision;
      |                 ^~~~~
a.cc:3:24: error: 'multiprecision' is not a namespace-name
    3 | using namespace boost::multiprecision;
      |                        ^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'uint128_t' was not declared in this scope; did you mean 'uint8_t'?
    6 |   uint128_t n=0;
      |   ^~~~~~~~~
      |   uint8_t
a.cc:7:12: error: expected ';' before 'k'
    7 |   uint128_t k=0;
      |            ^~
      |            ;
a.cc:8:8: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |   cin>>n;
      |        ^
      |        yn
a.cc:9:8: error: 'k' was not declared in this scope
    9 |   cin>>k;
      |        ^
a.cc:24:7: error: 'arr' was not declared in this scope
   24 |     t=arr[i];
      |       ^~~
a.cc:28:9: error: 'arr' was not declared in this scope
   28 |   cout<<arr[t-1]<<endl;
      |         ^~~
Language: C++

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long k = scanner.nextLong();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        int city = 1;
        for (long i = 0; i < k; i++) {
            city = a[city - 1];
        }
        System.out.println(city);

        /*
        long a = scanner.nextInt();
        long b = scanner.nextInt();
        long c = scanner.nextInt();
        long k = scanner.nextInt();
        if (a + b >= k) {
            System.out.println(a);
        }else {
            System.out.println(a - (k - (a + b)));
        }

         */
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

#include<iostream>

using namespace std;

int main(){
    int n,k;
    
    cin>>n>>m;
    int a[n+1]={0};
    
    for(int i=1;i<=n;i++){
        cin>>a[n];
    }
    
    int tmp,ans=1;
    while(1){
        tmp=a[ans];
        ans=tmp;
        k=k-1;
        if(k==0){
            break;
        }
    }
    cout<<ans<<"\n";
    
    return 0;
}

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

#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
int dp[1000005]

int main()
{ 
   fastio;
    ll a;
    unsigned ll k;
    cin>>a>>k;
    vector<ll> arr(a+1);
    range(i,1,a+1)
      cin>>arr[i];
    int curr=1;
    ;
    //dp[1]=1;
    memset(dp,-1,sizeof(dp));
    vi ans;
    //ans.pb(1);
    while(true)
    {
      //cout<<"run...";
       if(dp[curr]!=-1)
         break;
       else{ dp[curr]=curr;

            ans.pb(curr);
            curr=arr[curr];
           }
            
    }
    int out;
    ll x=(k+1)/ans.size();
    ll rem=(k+1)%ans.size();
    if(rem==0)out=ans.back();
    else out=ans[rem-1];
    cout<<out;

}



Compiler output:
a.cc:17:1: error: expected initializer before 'int'
   17 | int main()
      | ^~~
Language: C++

//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
const int N = 2e5 + 1;
int edg[N] = {0};
bool visit[N] = {0};
deque<int> path;
int last,k;

void bfs(int node){
	path.push_back(node);
	if(visit[edg[node]] && k){
		while(path.front()!=edg[node]){
			last = path.front();
			path.pop_front();
			k--;
		}
		return;
	}
	visit[edg[node]] = true;
	bfs(edg[node]);
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>edg[i];
	bfs(1);

	int len = path.size();
	if(k==0){
		cout<<last<<endl;
		return 0;
	}

	k%=len;
	while(k>=0){
		last = path.front();
		path.pop_front();
		k--;
	}
	cout<<last<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'void bfs(long long int)':
a.cc:20:12: error: reference to 'visit' is ambiguous
   20 |         if(visit[edg[node]] && k){
      |            ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:4:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:14:6: note:                 'bool visit [200001]'
   14 | bool visit[N] = {0};
      |      ^~~~~
a.cc:28:9: error: reference to 'visit' is ambiguous
   28 |         visit[edg[node]] = true;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:14:6: note:                 'bool visit [200001]'
   14 | bool visit[N] = {0};
      |      ^~~~~
Language: C++

#include <boost/multiprecision/cpp_int.hpp> 
#include<bits/stdc++.h>
using namespace std;
using namespace boost::multiprecision;
int main()
{
  uint128_t n=0;
  uint128_t k=0;
  cin>>n;
  cin>>k;
  int arr[n];
  for(int i=0;i<n;i++)
  cin>>arr[i];

 // k=k%n;
  int i=0;
  int t;
 // k++;
  while(k--)
  {
    t=arr[i];
    i=t-1;
   // k++;
  }
  cout<<arr[t-1]<<endl;
  //return 0;
}

Compiler output:
a.cc:1:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    1 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
int main(void){
int N,K,i=0,j=0;
scanf("%d %d",&N,&K);
int A[N+1];
for(i=0;i<N;i++){
scanf("%d",&A[i]);
}
i=0;
while(j+1=K){
i=A[i];
j++;
}

printf("%d",i);
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:10:10: error: lvalue required as left operand of assignment
   10 | while(j+1=K){
      |          ^
Language: C++

#include<iostream>
using namespace std;
int main();
{
  vector<int> arr1;
  int i=1,k,n,temp;
  cin>>n>>k;
  for(int i=1;i<=n;i++)
  {
    cin>>temp;
    arr1.push_back(temp);
  }
  while(k>0)
  {
    i=arr1[i];
    k--;
  }
  return 0;
}


Compiler output:
a.cc:4:1: error: expected unqualified-id before '{' token
    4 | {
      | ^
Language: C

#include<stdio.h>
int main(void){
int N,K,i=0,j=0;
scanf("%d %d",&N,&K);
int A[N+1];
for(i=0;i<N;i++){
scanf("%d",A[i]);
}
i=0;
while(j+1=K){
i=A[i];
j++;
}

printf("%d",i);
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:10:10: error: lvalue required as left operand of assignment
   10 | while(j+1=K){
      |          ^
Language: C++

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

int main(){
    
    int n;
    long long k;
    
    cin >> n >> k;
    
    vector<int> a(n+1);
    
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    
    int len = 0;
    int mod = 0;
    int next=a[1];
    
    vector<int> where(1,1);
    
    //where.push_back(1);
    //cout << where[where.size()-1] << endl;
    
    imt time=0;
    
    while(!len && time<n ){
        where.push_back(a[where[where.size()-1]]);
        
        time++;
        //cout << where[where.size()-1] << endl;
        
        for(int j=where.size()-2; j>-1; j--){
            
            if(where[where.size()-1]==where[j]){
                
                len = where.size()-1 - j;
                mod = j;
                break;
                
            }
        }
    }
    
    /*
    while(next != 1){
        next = a[next];
        len++;
    }
    */
    //cout << len << endl;
    //cout << mod << endl;
    
    if(k-mod<0){
        cout << where[k] << endl;
        return;
    }
    
    k -= mod;
    k %= len;
    
    next = where[mod];
    
    for(int i=1; i<k; i++){
        next = a[next];
    }
    
    cout << next << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'imt' was not declared in this scope; did you mean 'int'?
   26 |     imt time=0;
      |     ^~~
      |     int
a.cc:28:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   28 |     while(!len && time<n ){
      |                   ~~~~^~
a.cc:31:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
   31 |         time++;
      |         ^~~~
a.cc:31:13: error: lvalue required as increment operand
   31 |         time++;
      |             ^~
a.cc:57:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   57 |         return;
      |         ^~~~~~
Language: C++

#include<iostream>
using namespace std;
int main();
{
  vector<int> arr1;
  int i=1,k,n,temp;
  cin>>n>>k;
  for(int i=1;i<=n;i++)
  {
    cin>>temp;
    arr1.push_back(temp);
  }
  while(k>0)
  {
    i=arr1[i];
    k--;
  }
  return 0;
}

Compiler output:
a.cc:4:1: error: expected unqualified-id before '{' token
    4 | {
      | ^
Language: C++

#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
  ll n; ll k; cin >> n >> k;
  vector<ll> a(n+1);
  rep(i, n){
    cin >> a.at(i+1);
  }

  vector<bool> used(n+1, false);
  queue<ll> q, q1, q2;
  q.push(1);

  ll cnt = 0;
  ll ploop=0;
  while(!q.empty()){
    if(cnt==k){
      cout << now << endl;
      return 0;
    }
    ll now = q.front();
    used.at(now) = true;
    q.pop();
    cnt++;

    dump(now);
    if(!used.at(a.at(now))){
      q.push(a.at(now));
    }
    else{
      ploop = a.at(now);
      break; 
    }
  }


  q1.push(1);
  rep(i, n+1){
    used.at(i) = false;
  }
  used.at(1) = true;

  ll cnt2= 0;
  ll sp = 0;
  while(!q1.empty()){
    ll now = q1.front();
    if(now==ploop){
      sp = cnt2;
      break;
    }
    cnt2++;
    
    used.at(now) = true;
    q1.pop();

    if(!used.at(a.at(now))){
      q1.push(a.at(now));
    }
    else{
      break; 
    }
  }

  ll loop = (k-sp)%(ll)(cnt-sp);
  q2.push(1);
  rep(i, n+1){
    used.at(i) = false;
  }
  used.at(1) = true;
  dump(loop);

  ll cnt3= 0;
  bool st = false;
  while(!q2.empty()){
    ll now = q2.front();
    
    used.at(now) = true;
    q2.pop();

    if(now==ploop){
      st = true;
    }
   
    if(st && cnt3==loop){
      cout << now << endl;
      return 0;
    }
    else if(st) cnt3++;
    
    if(!used.at(a.at(now))){
     q2.push(a.at(now));
    }
    else{
      break; 
    }
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:15: error: 'now' was not declared in this scope; did you mean 'pow'?
   23 |       cout << now << endl;
      |               ^~~
      |               pow
Language: C++

#include <iostream>

using namespace std;

int main()
{
	int n, m = 0,l;
	__int64 k;
	int* a;
	cin >> n >>  k;
	l = k % n;
	a = new int[n];
	for (int i = 0; i < n; i++)cin >> a[i];
	
	for (int i = 0; i < l; i++)m = a[m] - 1;

	cout << m + 1;

	delete[] a;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
    8 |         __int64 k;
      |         ^~~~~~~
      |         __int64_t
a.cc:10:22: error: 'k' was not declared in this scope
   10 |         cin >> n >>  k;
      |                      ^
Language: C

#include <stdio.h>
#include <string.h>
 
int main(void) {
  int n, k, i, x;
  if(scanf("%d %d", &n, &k)==1);
  int a[n];
  for(i=0;i<n;i++) {
    if(scanf("%d", &a[i])==1);
  }
  x=1;
  for(i=0;i<k;i++) {
    y=a[x];
    x=y;
  }
  printf("%d", y);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:13:5: error: 'y' undeclared (first use in this function)
   13 |     y=a[x];
      |     ^
main.c:13:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

using namespace std;

int main()
{
	int n, m = 0,l;
	__int64 k;
	int* a;
	cin >> n >>  k;
	l = k % n;
	a = new int[n];
	for (int i = 0; i < n; i++)cin >> a[i];
	
	for (int i = 0; i < l; i++)m = a[m] - 1;

	cout << m + 1;

	delete[] a;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: '__int64' was not declared in this scope
    6 |         __int64 k;
      |         ^~~~~~~
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin >> n >>  k;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:8:22: error: 'k' was not declared in this scope
    8 |         cin >> n >>  k;
      |                      ^
a.cc:15:9: error: 'cout' was not declared in this scope
   15 |         cout << m + 1;
      |         ^~~~
a.cc:15:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C

#include <stdio.h>
#include <string.h>
 
int main(void) {
  int n, k, i, x;
  if(scanf("%d %d", &n, &k)==1);
  int a[n];
  for(i=0;i<n;i++) {
    if(scanf("%d", a[i])==1);
  }
  x=1;
  for(i=0;i<k;i++) {
    y=a[x];
    x=y;
  }
  printf("%d", y);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:13:5: error: 'y' undeclared (first use in this function)
   13 |     y=a[x];
      |     ^
main.c:13:5: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

/* LETS SEE IF U CAN PULL IT UP THIS TIME OR NOT */
/* WORK HARD MAN ! IT DEFINETELY AIN'T EASY FOR THE PRIZE IT HOLDS .... */
/* GET YOUR ASS TO WORK ALREADY */
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define pb emplace_back
#define range(v) v.begin(),v.end()
#define mod 1000000007
#define inf 1e15
#define pii pair<int,int>
#define ff first
#define ss second
// #define N --

using namespace std;

int32_t main() {
	fast
	int n, k;
	cin >> n >> k;
	vector<int> v(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	unordered_map<int, int> h, m;
	int cnt = 0, cs = 1, moves = k;

	while (moves and !m.count(cs)) {
		m[cs] = cnt;
		h[cnt] = cs;
		cs = v[cs];
		cnt++;
		moves--;
	}

	if (moves == 0)
		cout << cs << endl;

	k -= m[cs];
	cout << h[m[cs] + k % (Tcnt - m[cs])] << endl;

}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:41:32: error: 'Tcnt' was not declared in this scope; did you mean 'cnt'?
   41 |         cout << h[m[cs] + k % (Tcnt - m[cs])] << endl;
      |                                ^~~~
      |                                cnt
Language: C++

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

int main(){
    
    int n;
    long long k;
    
    cin >> n >> k;
    
    vector<int> a(n+1);
    
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    
    int len = 0;
    int mod = 0;
    int next=a[1];
    
    vector<int> where(1,1);
    
    //where.push_back(1);
    //cout << where[where.size()-1] << endl;
    
    while(!len){
        where.push_back(a[where[where.size()-1]]);
        
        //cout << where[where.size()-1] << endl;
        
        for(int j=where.size()-2; j>-1; j--){
            
            if(where[where.size()-1]==where[j]){
                
                len = where.size()-1 - j;
                mod = j;
                break;
                
            }
        }
    }
    
    /*
    while(next != 1){
        next = a[next];
        len++;
    }
    */
    //cout << len << endl;
    //cout << mod << endl;
    
    if(k-mod<0){
        cout << where[k] << endl;
        return;
    }
    
    k -= mod;
    k %= len;
    
    next = where[mod];
    
    for(int i=1; i<k; i++){
        next = a[next];
    }
    
    cout << next << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   54 |         return;
      |         ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() { 
  int n,a=0;
  long long k;
  cin>>n>>k;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
     cin >> vec.at(i);
      }
    }
  for(int i=0;i<k;i++){
    a=vec.at(a)-1;
    }
  cout<<a<<endl;
  return 0;
  }

Compiler output:
a.cc:12:3: error: expected unqualified-id before 'for'
   12 |   for(int i=0;i<k;i++){
      |   ^~~
a.cc:12:15: error: 'i' does not name a type
   12 |   for(int i=0;i<k;i++){
      |               ^
a.cc:12:19: error: 'i' does not name a type
   12 |   for(int i=0;i<k;i++){
      |                   ^
a.cc:15:3: error: 'cout' does not name a type
   15 |   cout<<a<<endl;
      |   ^~~~
a.cc:16:3: error: expected unqualified-id before 'return'
   16 |   return 0;
      |   ^~~~~~
a.cc:17:3: error: expected declaration before '}' token
   17 |   }
      |   ^
Language: C++

n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [-1 for _ in range(n)]

curr = 0
cnt = 0
k += 1
while True:
  if b[curr] != -1:
    loop = cnt - b[curr]
    break
  b[curr] = cnt
  cnt += 1
  k -= 1
  curr = a[curr] - 1

mod = k % loop
for i in range((mod-1) % loop):
  curr = a[curr] - 1

print(curr + 1)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, k = map(int, input().split())
      | ^
Language: C++

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll n, k, a[250000], in, r;

int main() {
  cin >> n >> k;
  rep(i, n) {
    cin >> a[i + 1];
  }

  if (k < 250000) {
    ll cp = 1;
    rep(i, k) {
      cp = [cp];
    }
    cout << cp << endl;
    return 0;
  }

  map<ll, ll> seen;
  ll cp = 1;
  rep(i, 250000) {
    cp = a[cp];
    if (seen[cp] != 0) {
      in = seen[cp];
      r = i + 1 - seen[cp];
      break;
    }
    seen[cp] = i + 1;
  }

  debug(r);
  debug(in);

  ll rm = (k - in) % r;

  debug(rm);

  rep(i, rm) {
    cp = a[cp];
  }
  cout << cp << endl;
}

Compiler output:
a.cc: In lambda function:
a.cc:31:16: error: expected '{' before ';' token
   31 |       cp = [cp];
      |                ^
a.cc: In function 'int main()':
a.cc:31:12: error: cannot convert 'main()::<lambda()>' to 'll' {aka 'long long int'} in assignment
   31 |       cp = [cp];
      |            ^~~~
      |            |
      |            main()::<lambda()>
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> town(N);

    for (int i = 0; i < N; i++) {
        cin >> town.at(i);
    }

    int now = 0;
    vector<int> check(N);
    check.at(0) = 1;
    int num = N;

    for (int i = 0; i < N; i++) {
        now = town.at(now) - 1;
        if (check.at(now) == 0) {
            check.at(now) = 1;
        }
        else {
            num = i + 1;
            break;
        }    
    }

    ans = K % num;

    now = 0;
    for (int i = 0; i < ans; i++) {
        now = town.at(now);
    }

    cout << now << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |     ans = K % num;
      |     ^~~
      |     abs
Language: C++

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

int main() {
  int N, K, goal, pla = 1
  cin >> N >> K;
  int arr[N];
  for(int i = 0; i < N; i++){
    cin >> arr[i];
  }
  
  while(K > 0){
    pla = arr[pla - 1];
    k--;
  }
  
  cout << pla << endl;
    
    
  
  return 0;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: expected ',' or ';' before 'cin'
    6 |   cin >> N >> K;
      |   ^~~
a.cc:14:5: error: 'k' was not declared in this scope
   14 |     k--;
      |     ^
Language: C

/*
Sharif Hasan - CSE, PUST
May 10, 2020 02: 27 PM 
*/
#include<bits/stdc++.h>
#define br cout<<"\n"

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
bool mark[2000000]={0};
/*Main function*/
int main()
{
long long n,m;
cin>>n>>m;
int arr[n+1];
FROM(1,i,n+1) cin>>arr[i];
int i=1;
vector <int> v;
while(1){
    v.pb(i);
    if(mark[i]==1) break;
    mark[i]=1;
    i=arr[i];
}
//reverse(v.begin(),v.end());
int k=0;
FOR(i,v.size()){
    if(v[i]==v[v.size()-1]){
        k=i;
        break;
    }
}

long long r=(m+k+1)%v.size();
//for(auto a:v) cout<<a<<" ";br;
//cout<<r;br;
cout<<v[r];br;
return 0;
}

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

import java.util.Scanner;

/**
 * @author Orange Summer
 * @date 2020/5/10-19:44
 */
public class contest167 {
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        String[] a=in.nextLine().split(" ");
        int number=Integer.parseInt(a[0]);
        long kingLike=Long.parseLong(a[1]);
        String[] b=in.nextLine().split(" ");
        int[] Ai=new int[number];
        for (int i=0;i<number;i++){
            Ai[i]=Integer.parseInt(b[i]);
        }
        int Index=0,go=1,location=1;
        for (int j=0;j<(kingLike-1);j++){
            Index=location;
            go=Ai[Index-1];
            location=Ai[go-1];
        }
        System.out.println(location);
    }
}


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

#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;

int main()
{
    int64_t N,K,i,j,ans,seg,root,Z,C,root2;
    bool T;
    T=true;
    ans=1;
    root=0;
    cin >> N >> K;
    Z=K;
    vector<int> A(N),B(N);
    rep(i,N){
        cin >> A[i];
    }
    while(T){
       B[ans-1]++;
       seg=A[ans-1];
       if(B[ans-1]<=1){
           ans=seg;
           Z--;
       }else{
           if(B[ans-1]==2){
               root++;
               ans=seg;
           Z--;
           }
       }
       if(Z==0){
           T=false;
       }
       if(B[ans-1]=>3){
           root2=root;
           T=false:
       }
    }
	C=Z%root2;
    if(root2>0){
        rep(i,C){
            ans=A[ans-1];
        }
        cout << ans <<endl;
        return 0;
    }else{
        cout << ans <<endl;
        return 0;
    }
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:20: error: expected primary-expression before '>' token
   47 |        if(B[ans-1]=>3){
      |                    ^
a.cc:49:19: error: expected ';' before ':' token
   49 |            T=false:
      |                   ^
      |                   ;
Language: Java

public class EL {
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        String[] a=in.nextLine().split(" ");
        int number=Integer.parseInt(a[0]);
        long kingLike=Long.parseLong(a[1]);
        String[] b=in.nextLine().split(" ");
        int[] Ai=new int[number];
        for (int i=0;i<number;i++){
            Ai[i]=Integer.parseInt(b[i]);
        }
        int Index=0,go=1,location=1;
        for (int j=0;j<(kingLike-1);j++){
            Index=location;
            go=Ai[Index-1];
            location=Ai[go-1];
        }
        System.out.println(location);
    }
}


Compiler output:
Main.java:1: error: class EL is public, should be declared in a file named EL.java
public class EL {
       ^
Main.java:3: error: cannot find symbol
        Scanner in=new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class EL
Main.java:3: error: cannot find symbol
        Scanner in=new Scanner(System.in);
                       ^
  symbol:   class Scanner
  location: class EL
3 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k;
  int n,x=1,y＝1,z=0;
  cin >> n >> k;
  vector<int> a(n+1);
  vector<int> b(n+1,0);
  for (int i = 1; i < n+1; i++) {
    cin >> a[i];
  }
  
  for (int i = 1; i < k+1; i++) {
    x=a[x];
    if(b[x]==0){
      b[x]=i;
    }else{
      y=i-b[x];
      z=i;
      break;
    }
  }
  if(y!=0&&z!=0){
    for (int i = z+1; i < (z+1)%y; i++) {
      x=a[x];
    }
  }
  cout << x << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:7: error: 'y' was not declared in this scope
   18 |       y=i-b[x];
      |       ^
a.cc:23:6: error: 'y' was not declared in this scope
   23 |   if(y!=0&&z!=0){
      |      ^
Language: C++

# include<bits/stdc++.h>
# include<unordered_map>
# include<unordered_set>
# include<prettyprint.hpp>
using namespace std;
# define ll long long
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n, k; cin >> n >> k;
    vector<ll> a(n+1, 0);
    for(ll i = 1; i <= n; i++) cin >> a[i];
    vector<ll> vis(n+1, 0);
    vector<ll> path;
    ll pos = 1;
    while(vis[pos] == 0){
        path.push_back(pos);
        vis[pos] = 1;
        pos = a[pos];
    }
    vector<ll> cycle;
    while (true){
        cycle.push_back(path.back());
        path.pop_back();
        if (cycle.back() == pos){
            break;
        }
    }
    if (k < path.size()){
        cout << path[k] << endl;
    }else{
        reverse(cycle.begin(), cycle.end());
        k-=path.size();
        k%=cycle.size();
        cout << cycle[k] << endl;
    }
    return 0;
}

Compiler output:
a.cc:4:10: fatal error: prettyprint.hpp: No such file or directory
    4 | # include<prettyprint.hpp>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
  long long n, k;
  vector<vector<long long>> G(N);
  for(int i = 0; i < N; i++){
    int a; cin >> a;a--;
    G[i].push_back(a);
  }
  long long strat = 0;
  for(long long i=0; i < k; i++){
    strat = G[strat];
  }
  cout << strat << endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:6:31: error: 'N' was not declared in this scope
    6 |   vector<vector<long long>> G(N);
      |                               ^
a.cc:13:20: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} to 'long long int' in assignment
   13 |     strat = G[strat];
      |                    ^
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 200002
typedef long long ll;
ll N,K;
ll A[MAX];
ll loop_start=0;
ll loop_end=0;
ll bit[MAX]={false};
ll memo[MAX] = {0};
void solve(ll town){
    bit[town] = true;
    memo[++loop_end] = town;
    if(bit[A[town]] == true){
        for(int i=1;i<=loop_end;i++){
            if(memo[i] == A[town]){
                loop_start = i;
                break;
            }
        }
    }
    else solve(A[town]);
}
ll main(){
    scanf("%lld %lld",&N,&K);
    for(ll i=1;i<=N;i++)
        scanf("%lld",A+i);
    solve(1);
    if(K<=loop_start) printf("%lld",memo[K]);
    else{
        printf("%lld",memo[loop_start + (K-loop_start+1)%(loop_end-loop_start+1)]);
    }
}


Compiler output:
a.cc:28:1: error: '::main' must return 'int'
   28 | ll main(){
      | ^~
Language: Java

//package ABC167;
import java.util.*;
public class Main2 {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		long k=sc.nextLong();
		
		int[] a=new int[n];
		int[] check=new int[n];
		
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		
		ArrayList<Integer> list=new ArrayList<>();
		int cur=1;
		int rec=1;
		//list.add(1);
		check[0]=1;
		while(true){
			
			if(check[cur-1]>1){
				int prev=check[cur-1];
				int hoge=(int)((k-prev+1)%(rec-prev));
				int ans=list.get(prev+hoge-2);
				System.out.println(ans);
				break;
			}
			else {
				check[cur-1]=rec;
				cur=a[cur-1];
				rec++;
				list.add(cur);
				//System.out.println(cur);
			}
		}
		
		
		
	}

}


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

#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

// int main()
// {
//     int n, m, x;
//     int c[12];
//     int a[12][12];


//     return 0;
// }

int main()
{
    ll n, k;
    int a[210000];
    bool b[210000];
    cin >> n >> k;

    vector<int> v;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i] -= 1;
        b[i] = false;
    }


    ll lp;
    ll start;
    vector<int> vv;
    
    v.push_back(0);
    b[0] = true;
    bool flag = true;

    while(flag)
    {
        int x = a[v[v.size()-1]];

            if (b[x])
            {
                int i;
                for (i = 0; i < v.size(); i++)
                {
                    if (v[i] == b)
                    break;
                }
                start = i;
                lp = v.size() - i;
                flag = false;
            }
        v.push_back(x);
        b[x] = true;
    }

    if (k < start)
    {
        cout << v[k]+1 << endl;
    }
    else
    {
        ll t = (k-start) % lp + start;
        cout << v[t] + 1 << endl;
    }
    return 0;
}

// int main()
// {

//     int n, m, k;
//     const ll mm = 998244353;
//     int ll ans = 0;

//     cin >> n >> m >> k;
//     return 0;
// }

Compiler output:
a.cc: In function 'int main()':
a.cc:52:30: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   52 |                     if (v[i] == b)
Language: C++

#include <iostream>
#include <vector>
using namespace std;
typedef long long LL;
const int LEN = 2e5 + 10;
int A[LEN], P[LEN];

int main() {
    int N;
    LL K;
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    vector<int> v;
    v.push_back(1);
    int pos = 1, repeat = 0;
    while (true) {
        if (find(v.begin(), v.end(), A[pos]) == v.end()) {
            v.push_back(A[pos]);
            pos = A[pos];
        } else {
            repeat = A[pos];
            break;
        }
    }
    /*
    cout << "v" << endl;
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
    */
    int len = v.size();
    pos = 0;
    while (pos <= N) {
        if (v[pos] != repeat) {
            pos += 1;
        } else {
            break;
        }
    }
    LL priod = len - pos, sub = pos;
    for (int i = 0; i < priod; i++) {
        P[i] = v[pos++];
    }
    /*
    for (int i = 0; i < priod; i++) {
        cout << P[i] << " ";
    }
    cout << endl;
     */
    cout << P[(K - sub) % priod] << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   19 |         if (find(v.begin(), v.end(), A[pos]) == v.end()) {
      |             ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:19:17: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   19 |         if (find(v.begin(), v.end(), A[pos]) == v.end()) {
      |             ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
int n,m,a[N];
ll k;
bool st[N];
int main()
{
	cin>>n>>k;
	k++;
	for(int i=1;i<=n;i++) cin>>a[i];
	vector<int> ve;
	int xx=1;
	while(!st[xx])
	{
		ve.push_back(xx);
		st[xx]=1;
		xx=a[xx];
	}
//	for(int i=0;i<ve.size();i++) cout<<ve[i]<<' ';
//	cout<<endl;
	int l,ds;
	for(int i=0;i<ve.size();i++)
		if(ve[i]==pos)
		{
			l=i;
			break;
		}
	ds=ve.size()-l;
	if(k>ve.size())
	{
		k-=ve.size();
		k%=ds;
		if(k==0) cout<<ve[ve.size()-1];
		else
			cout<<ve[k+l-1];
	}
	else cout<<ve[k-1];
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:27: error: 'pos' was not declared in this scope; did you mean 'pow'?
   25 |                 if(ve[i]==pos)
      |                           ^~~
      |                           pow
Language: C++

#include <iostream>
using namespace std;
 
int main(){
  int n,k;
  cin >>n>>k;
  int a[1000000];
  int b[n]={0};
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  bool loop=true;
  int i=0;
  int next=0;
  int x,y;
  while(loop){
    if (b[next]==0){
      b[next]=i;
      next=a[next];
      i+=1;
    } else{
      loop = false;
      x=b[next];
      y=i-b[next]:
    }
  }
  
  if (x>=k){
    l=0:
    for(int m=0; m<k;m++){
      l=a[l];
    }
  else{
    int answer=(k-x)%y;
    l=next;
    for (int m=0; m<answer; m++){
      l = a[l];
  }
  cout<<l<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:18: error: expected ';' before ':' token
   24 |       y=i-b[next]:
      |                  ^
      |                  ;
a.cc:29:5: error: 'l' was not declared in this scope
   29 |     l=0:
      |     ^
a.cc:30:18: error: 'm' was not declared in this scope
   30 |     for(int m=0; m<k;m++){
      |                  ^
a.cc:33:3: error: expected '}' before 'else'
   33 |   else{
      |   ^~~~
a.cc:28:12: note: to match this '{'
   28 |   if (x>=k){
      |            ^
a.cc:35:5: error: 'l' was not declared in this scope
   35 |     l=next;
      |     ^
a.cc:41:2: error: expected '}' at end of input
   41 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

bool visit[200020];
ll d[200020];

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  ll now=0,from=-1,len=0;
  while(k>0){
    if(visit[now]){
//      cout << len-d[now] <<endl;
      k%=len-d[now];
    }
    if(k==0)break;
    visit[now]=true;
    d[now]=len;
//    from=now;
    now=a[now];
    k--;
    len++;
//    cout << k << endl;
  }
  cout << now+1 << endl;
return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:8: error: reference to 'visit' is ambiguous
   25 |     if(visit[now]){
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:12:6: note:                 'bool visit [200020]'
   12 | bool visit[200020];
      |      ^~~~~
a.cc:30:5: error: reference to 'visit' is ambiguous
   30 |     visit[now]=true;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:12:6: note:                 'bool visit [200020]'
   12 | bool visit[200020];
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

bool visit[200020];
ll d[200020];

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  ll now=0,from=-1,len=0;
  while(k>0){
    if(visit[now]){
//      cout << len-d[now] <<endl;
      k%=len-d[now];
//      cout << k << endl;
    }
    if(k==0)break;
    visit[now]=true;
    d[now]=len;
//    from=now;
    now=a[now];
    k--;
    len++;
//    cout << k << endl;
  }
  cout << now+1 << endl;
return 0;}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:8: error: reference to 'visit' is ambiguous
   25 |     if(visit[now]){
      |        ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:12:6: note:                 'bool visit [200020]'
   12 | bool visit[200020];
      |      ^~~~~
a.cc:31:5: error: reference to 'visit' is ambiguous
   31 |     visit[now]=true;
      |     ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:12:6: note:                 'bool visit [200020]'
   12 | bool visit[200020];
      |      ^~~~~
Language: C++

#include <iostream>
using namespace std;

int main(){
  int n,k;
  cin >>n>>k;
  int a[1000000];
  int b[n]=0;
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  bool loop=true;
  int i=0;
  int next=0;
  int x,y;
  while(loop){
    if (b[next]==0){
      b[next]=i;
      next=a[next];
      i+=1;
    } else{
      loop = false;
      x=b[next];
      y=i-b[next]:
    }
  }
  int answer=(k-x)%y;
  if (x>=k){
    l=0:
    for(int m=0; m<k;m++){
      l=a[l];
    }
  else{
    l=next;
    for (int m=0; m<answer; m++){
      l = a[l];
  }
  cout<<l<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: array must be initialized with a brace-enclosed initializer
    8 |   int b[n]=0;
      |            ^
a.cc:9:7: error: 'i' was not declared in this scope
    9 |   for(i=0;i<n;i++){
      |       ^
a.cc:24:18: error: expected ';' before ':' token
   24 |       y=i-b[next]:
      |                  ^
      |                  ;
a.cc:29:5: error: 'l' was not declared in this scope
   29 |     l=0:
      |     ^
a.cc:30:18: error: 'm' was not declared in this scope
   30 |     for(int m=0; m<k;m++){
      |                  ^
a.cc:33:3: error: expected '}' before 'else'
   33 |   else{
      |   ^~~~
a.cc:28:12: note: to match this '{'
   28 |   if (x>=k){
      |            ^
a.cc:34:5: error: 'l' was not declared in this scope
   34 |     l=next;
      |     ^
a.cc:40:2: error: expected '}' at end of input
   40 | }
      |  ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); 
   int n;
   long long k;
   scanf("%d",&n);
  cin>>k;
   int a[n+1];
   for(int i=1;i<=n;i++){
	  scanf("%d",&a[i]);  
   }
   int j=1;
   int d=0;
   while(k--){
	 d = a[j];
	 j=d;
   } 
   printf("%d\n",d);

}
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); 
   int n;
   long long k;
   scanf("%d",&n);
  cin>>k;
   int a[n+1];
   for(int i=1;i<=n;i++){
	  int x;
	  scanf("%d",&x);
	  a[x] = i;    
   }
   int j=1;
   int d=0;
   while(k--){
	 d = a[a[j]]; 
   } 
   printf("%d\n",d);

}


Compiler output:
a.cc:26:5: error: redefinition of 'int main()'
   26 | int main()
      |     ^~~~
a.cc:3:5: note: 'int main()' previously defined here
    3 | int main()
      |     ^~~~
Language: C++

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

int ar[200001],n,m,t,r,be,now[200050],np,cy,w,ans;
bool ok[200001][200001],q;
long long k;

int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		cin>>ar[i];
	}
	np=1;
	now[1]=1;
	w=2;
	cy=-1;
	while (cy<be){
	    if (cy==-1) cy=0;
		if (ok[np][ar[np]]==false) {
			be++;
			cy+=be;
			cy=0;	
			ok[np][ar[np]]=true;
		}
		else cy++;
		np=ar[np];
		now[w]=np;
		w++;
		//cout<<np<<" ";
	}
	ans=be+((k-be)%cy);
	cout<<now[ans]<<"\n";
	return 0;
}



Compiler output:
/tmp/cckm90Gk.o: in function `main':
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cckm90Gk.o
a.cc:(.text+0x1dd): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/cckm90Gk.o
collect2: error: ld returned 1 exit status