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

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

vll a;
ll dist[220000];
ll roop_size;
ll roop_s;
ll roop_g;

void dfs(ll now){
  if(dist[a[now]]!=-1){
    roop_size=dist[now]-dist[a[now]]+1;
    roop_s=a[now];
    roop_g=now;
    return;
  }
  dist[a[now]]=dist[now]+1;
  dfs(a[now]);
}

int main(){cout<<fixed<<setprecision(20);
		   ll n,k;
           cin>>n>>k;
           if(k==727202214173249351)return;
           a.resize(n);
           rep(i,0,n){
             cin>>a[i];
             a[i]--;
           }
           rep(i,0,n)dist[i]=-1;
           dist[0]=0;
           dfs(0);
           if(k<=dist[roop_g]){
            rep(i,0,n)if(dist[i]==k)cout<<i+1<<endl; 
           }
           else{
             ll c=k;
             c-=dist[roop_s];
             c%=roop_size;
             if(c==0)c+=roop_size;
              // cout<<c<<endl;
             int ans=roop_s;
             rep(i,0,c){
               ans=a[ans];
             }
             cout<<ans+1<<endl;
           }
}

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

#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const int MAX = 2e5;
int n;
ll k; 
int a[MAX]; 
bool visited[MAX];
int main() {
    cin >> n >> k;
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    int pos = 0;
    visited[pos] = true;
    int cnt = 0;
    rep(i, n) {
        cnt++;
        pos = a[pos];
        if (visited[pos]) break;
    }
    int loop_start = pos;
    if (cnt >= k) {
        pos = 0;
        rep(i, k) {
            pos = a[pos];
        }
        ans = pos;
    } else {
        pos = 0;
        rep(i, n) {
            if (pos == loop_start) break;
            pos = a[pos];
            cnt--;
            k--;
        }
        int loop_size = cnt;
        pos = loop_start;
        rep(i, k%loop_size) {
            pos = a[pos];
        }
        ans = pos;
    }
    ans++;
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |         ans = pos;
      |         ^~~
      |         abs
a.cc:50:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |         ans = pos;
      |         ^~~
      |         abs
a.cc:52:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   52 |     ans++;
      |     ^~~
      |     abs
Language: Java

import java.util.*;
//kaze wo hiiteite atama ga mawaranai node kokode ittann owaru
public class Main{
  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];
    for(int i = 0;i<n;i++){
      a[i] = sc.nextInt()-1;
    }
    int now = 0;
    Map<Integer,Integer> m = new HashMap<>();
    int ans = 0;
    int m1 = -1;
    long shuuki = 0;
    for(int i = 0;i<n;i++){
      if(m.containsKey(now)){
        m1 = m.get(now);
        int m2 = i;
        shuuki = (long)m2 - (long)m1;
      }else{
        m.put(now,i);
      }
      now = a[now];
    }
    shuuki = k-(long) % shuuki;
    System.out.println(ans);


  }
}


Compiler output:
Main.java:27: error: illegal start of expression
    shuuki = k-(long) % shuuki;
                      ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define P pair<int,int>
int main()
{
	int n;
	ll k;
	cin>>n>>k;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	vector<int> s;
	vector<int> ord(n+1,-1);
	int c=1,l=0;
	int v=1;
	while(ord[v]==-1)
	{
		ord[v]=v.size();
		s.push_back(v);
		v=a[v-1];
	}
	c=s.size()-ord[v]
	l=ord[v];
	if(k<1) cout<<s[k]<<endl;
	else
	{
		k-=l;
		k%=c;
		cout<<s[l+k]<<endl;
	} 
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:26: error: request for member 'size' in 'v', which is of non-class type 'int'
   19 |                 ord[v]=v.size();
      |                          ^~~~
a.cc:23:26: error: expected ';' before 'l'
   23 |         c=s.size()-ord[v]
      |                          ^
      |                          ;
   24 |         l=ord[v];
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define P pair<int,int>
int main()
{
	int n;
	ll k;
	cin>>n>>k;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	vector<int> s;
	vector<int> ord(n+1,-1);
	int c=1,l=0;
	int v=1
	while(ord[v]==-1)
	{
		ord[v]=v.size();
		s.push_back(v);
		v=a[v-1];
	}
	c=s.size()-ord[v]
	l=ord[v];
	if(k<1) cout<<s[k]<<endl;
	else
	{
		k-=l;
		k%=c;
		cout<<s[l+k]<<endl;
	} 
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: expected ',' or ';' before 'while'
   17 |         while(ord[v]==-1)
      |         ^~~~~
a.cc:23:26: error: expected ';' before 'l'
   23 |         c=s.size()-ord[v]
      |                          ^
      |                          ;
   24 |         l=ord[v];
      |         ~
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> s;
int n,k,a[200001],ord[200001];
signed main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	int cnt=1;
	while(ord[cnt]==0)
	{
		ord[cnt]=s.size()
		s.push_back(cnt);
		cnt=a[cnt];
	}
	int l=ord[cnt];
	int c=s.size()-ord[cnt];
	if(k<l)
		cout<<s[k];
	else
	{
		k-=l;
		k%=c;
		cout<<s[l+k];
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:34: error: expected ';' before 's'
   14 |                 ord[cnt]=s.size()
      |                                  ^
      |                                  ;
   15 |                 s.push_back(cnt);
      |                 ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n;
long long k;
set<int> s;
int a[200010];
int main(){
	cin>>n;
	cin>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int j=a[1];
	s.insert(1);
	vector<int> v;
	v.push_back(1);
	v.push_back(j);
	int more;
	while(1){
		s.insert(j);
		j=a[j];
		v.push_back(j);
		if(s.find(j)!=s.end()){more=j;break;}
	}
	long long num=0;
	k-=num;
	while(v[0]!=more&&more!=1)v.erase(v.begin()),num++;
	if(v.size()==1){
		cout<<v[0]<<endl;
		return 0;
	}
	v.erase(v.begin());
	/*
	for(int i=0;i<v.size();i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
	cout<<k<<endl;
	*/
	if(v.size()>=k){
		cout<<v[k-1]<<endl;
	}
	if(k%v.size()==0){
		cout<<v[v.size()-1]<<endl;
	}
	else cout<<v[k%long longv.size()-1]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:24: error: expected primary-expression before 'long'
   46 |         else cout<<v[k%long longv.size()-1]<<endl;
      |                        ^~~~
a.cc:46:24: error: expected ']' before 'long'
   46 |         else cout<<v[k%long longv.size()-1]<<endl;
      |                        ^~~~
      |                        ]
Language: C++

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

int main() {
  long N,K;cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);//　テレポーター指示
 // vector<int> B(N+1,0);//これまで到着した町
 // B.at(0)=1;
  set<int> B;
  B.insert(1);
  long count=0;
  int temp=1;
  long J;
  bool can=true;
  int repeat=0;
 /* while(can){
    count++;
    temp=A.at(temp-1);
    B.at(count)=temp;
    for(int i=0;i<count;i++){
      if(B.at(i)==temp){
        can=false;
        J=i;
        break;
      }
    }
  }
  repeat=count-J;
  if(K>count){
    K -= count;
    long ans=(K%repeat)+J;
    cout<<B.at(ans)<<endl;
  }
  else cout<<B.at(K)<<endl;*/
  while(can){
    count++;
    temp=A.at(temp-1);
    if(B.count(temp)) can=false;
    else B.insert(temp);
  }
  J=temp;
  while(true){
    repeat++;
    temp=A.at(temp-1);
    if(temp==J) break;
  }
  
  int ans=1;
  if(K<=J){
    for(int i=0;i<K;i++) ans=A.at(ans-1);
    cout<<ans<<endl;
  else{
    K =(K-J)%repeat+J;
    for(int i=0;i<K;i++) ans=A.at(ans-1);
    cout<<ans<<endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:3: error: expected '}' before 'else'
   53 |   else{
      |   ^~~~
a.cc:50:11: note: to match this '{'
   50 |   if(K<=J){
      |           ^
Language: C++

include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,K; cin>>N>>K;
  vector<int64_t> A(N),S;
  rep(i,N){
    cin>>A.at(i);
    A.at(i)--;
  }
  
  vector<bool> seen(N,true);
  int64_t k=0,l=0;
  
  while(seen.at(k)){
    seen.at(k)=false;
    S.push_back(k);
    k=A.at(k);
  }
  while(S.at(l)!=k) l++;
  if(K<=l) cout<<S.at(K)+1;
  else{
    K-=l;
  int64_t t=S.size()-l,q=K%t;
  cout<<S.at(q+l)+1;
  }
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc:4:1: error: 'int64_t' does not name a type
    4 | int64_t MOD=1000000007;
      | ^~~~~~~
a.cc:1:1: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
  +++ |+#include <cstdint>
    1 | include <bits/stdc++.h>
a.cc: In function 'int main()':
a.cc:8:3: error: 'int64_t' was not declared in this scope
    8 |   int64_t N,K; cin>>N>>K;
      |   ^~~~~~~
a.cc:8:3: note: 'int64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:8:16: error: 'cin' was not declared in this scope
    8 |   int64_t N,K; cin>>N>>K;
      |                ^~~
a.cc:8:21: error: 'N' was not declared in this scope
    8 |   int64_t N,K; cin>>N>>K;
      |                     ^
a.cc:8:24: error: 'K' was not declared in this scope
    8 |   int64_t N,K; cin>>N>>K;
      |                        ^
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int64_t> A(N),S;
      |   ^~~~~~
a.cc:9:19: error: 'A' was not declared in this scope
    9 |   vector<int64_t> A(N),S;
      |                   ^
a.cc:9:24: error: 'S' was not declared in this scope
    9 |   vector<int64_t> A(N),S;
      |                        ^
a.cc:15:10: error: expected primary-expression before 'bool'
   15 |   vector<bool> seen(N,true);
      |          ^~~~
a.cc:16:10: error: expected ';' before 'k'
   16 |   int64_t k=0,l=0;
      |          ^~
      |          ;
a.cc:18:9: error: 'seen' was not declared in this scope
   18 |   while(seen.at(k)){
      |         ^~~~
a.cc:18:17: error: 'k' was not declared in this scope
   18 |   while(seen.at(k)){
      |                 ^
a.cc:23:14: error: 'l' was not declared in this scope
   23 |   while(S.at(l)!=k) l++;
      |              ^
a.cc:23:18: error: 'k' was not declared in this scope
   23 |   while(S.at(l)!=k) l++;
      |                  ^
a.cc:24:9: error: 'l' was not declared in this scope
   24 |   if(K<=l) cout<<S.at(K)+1;
      |         ^
a.cc:24:12: error: 'cout' was not declared in this scope
   24 |   if(K<=l) cout<<S.at(K)+1;
      |            ^~~~
a.cc:27:10: error: expected ';' before 't'
   27 |   int64_t t=S.size()-l,q=K%t;
      |          ^~
      |          ;
a.cc:28:3: error: 'cout' was not declared in this scope
   28 |   cout<<S.at(q+l)+1;
      |   ^~~~
a.cc:28:14: error: 'q' was not declared in this scope
   28 |   cout<<S.at(q+l)+1;
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  
  vector<int> s;
  vector<int> ord(n+1,-1);
  int c=1;l=0;
  int v=1;
  while(ord[v]==-1){
    ord[v]=s.size();
    s.push_back(v);
    v=a[v-1];
  }
  c=s.size()-ord[v];
  l=ord[v];
  if(l>k){
    cout<<s[k]<<endl;
  }else{
    k-=l;
    k%=c;
    cout<<s[l+k]<<endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: 'l' was not declared in this scope
   12 |   int c=1;l=0;
      |           ^
Language: C++

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

int main() 
{
int n
long long int k;
cin>>n>>k;
vector<int>visit(n+1);
vector<int>arr(n+1);
for(int i=1;i<=n;i++)
{
      cin>>arr[i];    
}
int pos=1;
int len=0;
while(visit[pos]==0)
{     
          visit[pos]=1;
          pos=arr[pos];
          len++;
}
int pos1=arr[pos];
int cycle=1;
while(pos1!=pos)
{
          pos1=arr[pos1];
          cycle++;
}
 
int j;
if(k<=(len-cycle))
{
          j=k;
          pos=1;
}
else
{
          k=(k-(len-cycle));
          j=k%cycle;
}
 
while(j--)
{
          pos=arr[pos];
}
cout<<pos<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:1: error: expected initializer before 'long'
    7 | long long int k;
      | ^~~~
a.cc:8:6: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 | cin>>n>>k;
      |      ^
      |      yn
a.cc:8:9: error: 'k' was not declared in this scope
    8 | cin>>n>>k;
      |         ^
Language: C++

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

void solve() {
    ll n, k;
    cin >> n >> k;
    int a[n + 1];
    vector<int> reach(n, -1);
    for(int i = 1; i <= n; i++)
        cin >> a[i];

    int loop = 0, now = 1;
    while(true) {
        if(reach[now] != -1)
            break;
        if(k == loop) {
            cout << now << "\n";
            return;
        }
        reach[now] = loop;
        now = a[now];
        loop++;
    }

    k -= reach[now];
    loop -= reach[now];

    k = k % loop;
    for(int i = 0; i < k; i++)
        now = a[now];

    cout << now << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:6:5: error: 'll' was not declared in this scope
    6 |     ll n, k;
      |     ^~
a.cc:7:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |     cin >> n >> k;
      |            ^
      |            yn
a.cc:7:17: error: 'k' was not declared in this scope
    7 |     cin >> n >> k;
      |                 ^
a.cc:11:16: error: 'a' was not declared in this scope
   11 |         cin >> a[i];
      |                ^
a.cc:22:15: error: 'a' was not declared in this scope
   22 |         now = a[now];
      |               ^
a.cc:31:15: error: 'a' was not declared in this scope
   31 |         now = a[now];
      |               ^
At global scope:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<iostream>
using namespace std;
int main()
{
long long int n,k,count=0,i;
cin>>n>>k;
long long int a[n];
for(i=0;i<n;i++)
cin>>a[i];
i=0;
while(count<k)
{
i=A[i]-1;
count++;
}
cout<<i+1;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'A' was not declared in this scope
   13 | i=A[i]-1;
      |   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	ll k;
	cin>>n>>k;
	int arr[n];
	vector<int> g[n];
	bool vis[n]={};
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	k--;
	int x = arr[0];
	bool cycle = false;
	int cnt=0;
	for(int i=0; i<k && !cycle; i++){
		if(!vis[x-1]){
			vis[x-1]=1;
			x = arr[x-1];
			cnt++;
		}
		else {
			cycle = true;
			c=x;
		}
	}
	k-=cnt;
	memset(vis, 0, sizeof(vis));
	int comp = 0;
	vector<int> path;
	while(!vis[x-1]){
		path.push_back(x);
		vis[x-1]=1;
		x = arr[x-1];
		comp++;
	}
	int m = k%comp;
	cout<<path[m]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: 'c' was not declared in this scope
   26 |                         c=x;
      |                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,K; cin>>N>>K;
  vector<int>A(N);
  vector<bool>B(N,false);
  B[0]=true;
  rep(i,N)cin>>A[i];
  B[0]=true;
  vector<int>C(N);
  C[0]=0;
  for(int i=0;i<N+2;i++){
    C[i+1]=A[C[i]]-1;
    if(B[A[C[i]]-1]==true){
      for(int j=0;j<i;j++){
        if(C[j]==C[i])cout<<C[(K-j)%i]<<endl;
      }
    }
    B[A[C[i]]]=true;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   rep(i,N)cin>>A[i];
      |       ^
a.cc:8:3: error: 'rep' was not declared in this scope
    8 |   rep(i,N)cin>>A[i];
      |   ^~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll n, k;
    cin >> n >> k;
    
    vector<vector<int>> next(60, vector<int>(n));
    for(int v = 0; v < n; v++) {
        cin >> next[0][v]; next[0][v]--;
    }

    for(int d = 0; d+1 < 60; d++) {
        for(int v = 0; v < n; v++) {
            next[d+1][v] = next[d][next[d][v]];
        }
    }

    int v = 0;
    for(int d = 0; d < 60; d++) {
        if (K & (1L<<d)) v = next[d][v];
    }

    cout << v+1 << endl;

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: 'K' was not declared in this scope
   34 |         if (K & (1L<<d)) v = next[d][v];
      |             ^
Language: C++

#include <iostream>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

const int N = 200010;
ll a[N];
bool vis[N];

vector<ll> vec;

int main(){
    ll n, k;
	cin >> n >> k;

	for (int i = 0; i < n; i++) cin >> a[i];

    ll buffer = 1;

    for (int i = 0; i < n; i++) {
		vis[buffer] = 1;
        vec.push_back(buffer);
		buffer = a[buffer - 1];
        if (vis[buffer] == 1) {
            break;
        }
    }

    auto it = find(vec.begin(), vec.end(), buffer);

    ll Length = vec.end() - it;

    ll step = it - vec.begin();

    ll now;
    if (k > step) {
        now = (k - step) % Length;
    } else {
        now = (k - step);
    }
    printf("%lld\n", vec[step + now]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:19: error: no matching function for call to 'find(std::vector<long long int>::iterator, std::vector<long long int>::iterator, ll&)'
   30 |     auto it = find(vec.begin(), vec.end(), buffer);
      |               ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:30:19: note:   '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   30 |     auto it = find(vec.begin(), vec.end(), buffer);
      |               ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    ll k;
    cin>>n>>k;
    vector<int> A(n);
    rep(i,n){
        cin>>A[i];
        A[i]--;
    }

    deque<int> a; // 繰り返しの部分
    vector<bool> seen(N, false); // 一度見たかどうか
    int cur = 0;
    while (true) {
        // 一度通った頂点を見つけたときの処理
        if (seen[cur]) {
            while (a[0] != cur) {
                // 最初の余計な数手分を除去する
                --K;
                a.pop_front();

                // 繰り返す前に K が限界になったらリターン
                if (K == 0) {
                    cout << a[0]+1 << endl;
                    return 0;
                }
            }
            break;
        }
        // 最初は愚直にシミュレーションしつつ、履歴をメモしていく
        a.push_back(cur);
        seen[cur] = true;
        cur = A[cur];
    }
    cout << a[K % a.size()]+1 << endl;

    
}



Compiler output:
a.cc: In function 'int main()':
a.cc:20:23: error: 'N' was not declared in this scope
   20 |     vector<bool> seen(N, false); // 一度見たかどうか
      |                       ^
a.cc:27:19: error: 'K' was not declared in this scope
   27 |                 --K;
      |                   ^
a.cc:43:15: error: 'K' was not declared in this scope
   43 |     cout << a[K % a.size()]+1 << endl;
      |               ^
Language: C++

#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
 
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9 + 7;
const ll MAX = 1e6+7;
const ll inf = 1e9+1;
ll a[MAX];
bool visit[MAX];
vi city;
int main() {
  fastio;
  ll ans,n,k,cont=0;
  cin>>n>>k;
  f(i,1,n+1){
    cin>>a[i];
  }
  ll pos=1;
  while(!visit[pos]){
    visit[pos]=true;
    city.pb(pos);
    pos=a[pos];
  }
  f(i,0,sz(city)){
    if(city[i]==pos) break;
    cont++;
  }
  if(k<cont) {cout<<city[k]<<endl;return 0;}
  ans = city[cont+ (k-cont)%(sz(city)-cont)];
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:10: error: reference to 'visit' is ambiguous
   40 |   while(!visit[pos]){
      |          ^~~~~
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:30:6: note:                 'bool visit [1000007]'
   30 | bool visit[MAX];
      |      ^~~~~
a.cc:41:5: error: reference to 'visit' is ambiguous
   41 |     visit[pos]=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:30:6: note:                 'bool visit [1000007]'
   30 | bool visit[MAX];
      |      ^~~~~
Language: C

#include<stdio.h>
int main()
{
  int n,k,c=0,i=1;
  scanf("%d%d",&n&,k);
  int a[n];
  for(int i=0;i<n;++i)
    scanf("%d",&a[i]);
  while(c!=k)
  {
    i=a[i];
    ++c;
  }
  printf("%d",i);
}

Compiler output:
main.c: In function 'main':
main.c:5:19: error: expected expression before ',' token
    5 |   scanf("%d%d",&n&,k);
      |                   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=longlong;
using P=pair<int,int>;

int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(false);
   int n;ll k;
   cin >>n>>k;
   vector<int> a(n);
   for (int i=0;i<n;++i) cin >>a[i];

   vector<int> s;//訪れた頂点をメモ
   vector<int> ord(n+1,-1);
   int c=1,l=0;
   {
       int v=1;
       while (ord[v]==-1)//まだ訪れていないなら
       {
           ord[v]=s.size();
           s.push_back(v);
           v=a[v-1];
       }
       c=s.size()-ord[v];
       l=ord[v];
   }
   if (k<1) cout << s[k] << endl;
   else {
       k-=1;
       k%=c;
       cout << s[l+k] << endl;
   }
   return 0;
}

Compiler output:
a.cc:3:10: error: 'longlong' does not name a type
    3 | using ll=longlong;
      |          ^~~~~~~~
a.cc: In function 'int main()':
a.cc:9:10: error: 'll' was not declared in this scope
    9 |    int n;ll k;
      |          ^~
a.cc:10:13: error: 'k' was not declared in this scope
   10 |    cin >>n>>k;
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=longlong;
using P=pair<int,int>;

int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(false);
   int n;
   cin >>n;
   vector<int> a(n);
   for (int i=0;i<n;++i) cin >>a[i];

   vector<int> s;//訪れた頂点をメモ
   vector<int> ord(n+1,-1);
   int c=1,l=0;
   {
       int v=1;
       while (ord[v]==-1)//まだ訪れていないなら
       {
           ord[v]=s.size();
           s.push_back(v);
           v=a[v-1];
       }
       c=s.size()-ord[v];
       l=ord[v];
   }
   if (k<1) cout << s[k] << endl;
   else {
       k-=1;
       k%=c;
       cout << s[l+k] << endl;
   }
   return 0;
}


Compiler output:
a.cc:3:10: error: 'longlong' does not name a type
    3 | using ll=longlong;
      |          ^~~~~~~~
a.cc: In function 'int main()':
a.cc:28:8: error: 'k' was not declared in this scope
   28 |    if (k<1) cout << s[k] << endl;
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=longlong;
using P=pair<int,int>;

int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(false);
   int n;
   cin >>n;
   vector<int> a(n);
   for (int i=0;i<n;++i) cin >>a[i];

   vector<int> s;//訪れた頂点をメモ
   vector<int> ord(n+1,-1);
   int c=1,l=0;
   {
       int v=1;
       while (ord[v]==-1)//まだ訪れていないなら
       {
           ord[v]=s.size();
           s.push_back(v);
           v=a[v-1]
       }
       c=s.size()-ord[v];
       l=ord[v];
   }
   if (k<1) cout << s[k] << endl;
   else {
       k-=1;
       k%=c;
       cout << s[l+k] << endl;
   }
   return 0;
}

Compiler output:
a.cc:3:10: error: 'longlong' does not name a type
    3 | using ll=longlong;
      |          ^~~~~~~~
a.cc: In function 'int main()':
a.cc:23:20: error: expected ';' before '}' token
   23 |            v=a[v-1]
      |                    ^
      |                    ;
   24 |        }
      |        ~            
a.cc:28:8: error: 'k' was not declared in this scope
   28 |    if (k<1) cout << s[k] << endl;
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=Longlong;
using P=pair<int,int>

int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(false);
   int n;
   cin >>n;
   vector<int> a(n);
   for (int i=0;i<n;++i) cin >>a[i];

   vector<int> s;//訪れた頂点をメモ
   vector<int> ord(n+1,-1);
   int c=1,l=0;
   {
       int v=1;
       while (ord[v]==-1)//まだ訪れていないなら
       {
           ord[v]=s.size();
           s.push_back(v);
           v=a[v-1]
       }
       c=s.size()-ord[v];
       l=ord[v];
   }
   if (k<1) cout << s[k] << endl;
   else {
       k-=1;
       k%=c;
       cout << s[l+k] << endl;
   }
   return 0;
}

Compiler output:
a.cc:3:10: error: 'Longlong' does not name a type
    3 | using ll=Longlong;
      |          ^~~~~~~~
a.cc:4:9: error: two or more data types in declaration of 'type name'
    4 | using P=pair<int,int>
      |         ^~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;



int main(void) {
	int N;
	long long K;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<int> s;
	vector<int> ord(N + 1, -1);
	int N1 = 1, N2 = 0;
	{
		int v = 1;
		while (ord[v] == -1) {
			ord[v] = s.size();
			s.push_back[v];
			v = a[v - 1];
		}
		N1 = ord[v];
		N2 = s.size();
	}
	if (K < N1) {
		cout << s[K] << endl;
	}
	else {
		K = K - N1;
		int x = K % (N2 - N1);
		cout << s[N1+x] << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:36: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   23 |                         s.push_back[v];
      |                                    ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
#define INF 100000000000007
using namespace std;
using pii=pair<int,int>;
using LL=int64_t;

int main(){
    int n;
    LL k;
    cin>>n>>k;
    
    
    vector<int> to(n+1);
    vector<bool> is_reached(n+1,false);
    int loop_start;

    
    
    REP(i,n){
        int a;
        cin>>a;
        to.at(i+1)=a;

    }
    is_reached.at(1)=true;
    int now1=1;
    for(int i=1;i<=n;i++){
        
        int next=to.at(now1);
        if(is_reached.at(next)){
            loop_start=next;
            break;
        }
        is_reached.at(next)=true;
        
        now1=next;
    }


    int now1=1;
    while(now1!=loop_start){
        if(k==0){
            cout<<now1<<endl;
            return 0;
        }
        k--;
        now1=to.at(now1);
    }

    REP(i,n+1){
        is_reached.at(i)=false;
    }
    
    is_reached.at(loop_start)=true;
    int period=1;
    int next=to.at(loop_start);
    while(true){
        if(is_reached.at(next)){
            break;
        }
        
        is_reached.at(next)=true;
        next=to.at(next);
        period++;
    }

    int64_t step=k%period;
    int now=loop_start;
    /*cout<<loop_start<<endl;
    cout<<period<<endl;
    cout<<step<<endl;*/
    REP(i,step){
        now=to.at(now);
    }

    cout<<now<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:9: error: redeclaration of 'int now1'
   53 |     int now1=1;
      |         ^~~~
a.cc:39:9: note: 'int now1' previously declared here
   39 |     int now1=1;
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int N; ll K;
  	cin>>N>>K;
  	vector<int> a(N);
  	rep(i,N) cin>>a[i];
  
  	vector<int> s;
  	vector<int> ord(n+1,-1);
  	int c=1, l=0;
  {
    int v=1;
    while(ord[v]==-1){
     	ord[v]=s.size();
      	s.push_back(v);
      	v=a[v-1];
    }
    c=s.size()-ord[v];
    l=ord[v];
  }
  	if(k<l) cout<<s[k]<<endl;
  	else{
     	k-=l;
      	k%=c;
      	cout<<s[l+k]<<endl;
    }
    
   
  	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:25: error: 'n' was not declared in this scope
   18 |         vector<int> ord(n+1,-1);
      |                         ^
a.cc:30:12: error: 'k' was not declared in this scope
   30 |         if(k<l) cout<<s[k]<<endl;
      |            ^
Language: C++

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n,k;
  cin >> n >> k;
  int64_t a[n] = {};
  for(int64_t i=0;i<n;i++){
    cin >> a[i];
    a[i] -= 1;
  }

  int64_t visited[n] = {};
  int64_t current = 0;
  int64_t loopCount = 0;
  for(int64_t i=0;i<n;i++){
    visited[i] = -1;
  }
  for(int64_t i=0;i<n+1;i++){
    if(visited[current]!=-1){
      loopCount = i-visited[current];
      break;
    }
    visited[current] = i;
    current = a[current];
  }
  if(k<visited[current]){
    current = 0;
  	for(int64_t i=0;i<newK;i++){
    	current = a[current];
  	}
    cout << current << endl;
    return 0;
  }
  int64_t newK = (k-visited[current])%loopCount;
  for(int64_t i=0;i<newK;i++){
    current = a[current];
  }
  cout << current+1 << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:100:27: error: 'newK' was not declared in this scope
  100 |         for(int64_t i=0;i<newK;i++){
      |                           ^~~~
Language: C++

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

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];

    deque<int> a; // 繰り返しの部分
    set<int> se; // 一度通った頂点
    int cur = 0;
    while (true) {
        // 一度通った頂点を見つけたときの処理
        if (se.count(cur)) {
            while (a[0] != cur) {
                // 最初の余計な数手分を除去する
                --K;
                a.pop_front();

                // 繰り返す前に K が限界になったらリターン
                if (K == 0) return a[0] + 1;
            }
            break;
        }
        // 最初は愚直にシミュレーションしつつ、履歴をメモしていく
        a.push_back(cur);
        se.insert(cur);
        cur = A[cur];
    }
    return a[K % D.size()] + 1;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:18: error: 'D' was not declared in this scope
   32 |     return a[K % D.size()] + 1;
      |                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long a,n,k;
int d[70][200001],i,j,g;
int main()
{
    cin>>n>>k;
    for(i=0;i<n;++i)
	{
    	cin>>a;
    	d[0][i]=a-1;
    }
    for(i=0;i<=60;++i)
    	for(j=0;j<n;++j)d[i+1][j]=d[i][d[i][j]];
    for(i=0;i<=60;++i)if(k&(1LL<<i))g=d[i][now];
    cout<<g+1;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:44: error: 'now' was not declared in this scope; did you mean 'pow'?
   15 |     for(i=0;i<=60;++i)if(k&(1LL<<i))g=d[i][now];
      |                                            ^~~
      |                                            pow
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long a,n,k;
int d[70][200001],i,j,n=0;
int main()
{
    cin>>n>>k;
    for(i=0;i<n;++i)
	{
    	cin>>a;
    	d0][i]=a-1;
    }
    for(i=0;i<=60;++i)
      	for(j=0;j<n;++j)d[i+1][j]=d[i][d[i][j]];
    for(i=0;i<=60;++i)if(k&(1LL<<i))now=d[i][now];
	cout<<n+1;
	return 0;
}

Compiler output:
a.cc:4:23: error: conflicting declaration 'int n'
    4 | int d[70][200001],i,j,n=0;
      |                       ^
a.cc:3:13: note: previous declaration as 'long long int n'
    3 | long long a,n,k;
      |             ^
a.cc: In function 'int main()':
a.cc:11:9: error: 'd0' was not declared in this scope; did you mean 'y0'?
   11 |         d0][i]=a-1;
      |         ^~
      |         y0
a.cc:15:37: error: 'now' was not declared in this scope; did you mean 'pow'?
   15 |     for(i=0;i<=60;++i)if(k&(1LL<<i))now=d[i][now];
      |                                     ^~~
      |                                     pow
Language: C++

#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

const double PI=3.14159265358979323846; // or M_PI


void Main() {
    ll n, k, d, count=0, roop=0, roop_start=0, in_a;

    cin >> n >> k;
    vector<ll> a;
    vector<ll> dest;
    vector<ll> ikeru_check(n + 1, -1);

    a.push_back(0);
    REP(i, n) {
        cin >> in_a;
        a.push_back(in_a);
    }

    d = 1;
    REP(i, k) {
        if (ikeru_check[d] != -1) {
            roop_start = ikeru_check[d];
            roop = count - ikeru_check[d];
            break;
        }
        ikeru_check[d] = count;
        dest.push_back(d);
        d = a[d];
        count++;
    }

    if (k < count) {
        COUT(dest[k]);
    }
    else {
        if (k % roop < roop_start) {
            COUT(dest[(k % roop) + roop]);
        }
        else {
            COUT(dest[(k % roop)]);
        }
    }

Compiler output:
a.cc: In function 'void Main()':
a.cc:70:6: error: expected '}' at end of input
   70 |     }
      |      ^
a.cc:33:13: note: to match this '{'
   33 | void Main() {
      |             ^
Language: C++

/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
#include <show_vec.hh>


#define DEBUG  if(false)

using namespace std;

using ll = long long;
#define LINE printf("LINE : %d\n", __LINE__);
#define loop(i, n) for(i = 0; i < n; i++)
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  int N; cin >> N;
  ll K; cin >> K;
  vec<int> Next(N, 0), visited(N, 0);
  for(int i = 0; i < N; i++){
    cin >> Next[i];
    Next[i]--;
  }
  int curr  = 0;
  visited[0] = 1;
  int loop_first, loop_end;
  int count = 0;
  while(true){
    int next = Next[curr];
    if(visited[next] == 1){
      loop_first = next;
      loop_end = curr;
      break;
    }else{
      visited[next] = 1;
      curr = next;
      count++;
    }
  }
  int count_ = 0;
  curr = 0;
  for(int i = 0; i < count; i++){

    if(curr == loop_first){
      break;
    }else{
      count_++;
      curr = Next[curr];
    }
  }

  int step = 0;
  if(K <= count){
    step = K;
  }else{
    step = ((K-count_) % (count - count_ + 1)) + count_;
  }
  DEBUG printf("count : %d\n", count);
  DEBUG printf("count_ : %d\n", count_);
  int moved;
  curr = 0;
  DEBUG printf("step : %d\n", step);
  for(int i = 0; i < step; i++){
    curr = Next[curr];
  }
  cout << curr+1 << endl;
  return 0;
}


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

/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>


#define DEBUG  if(false)

using namespace std;

using ll = long long;
#define LINE printf("LINE : %d\n", __LINE__);
#define loop(i, n) for(i = 0; i < n; i++)
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  int N;
  ll K;
  cin >> N >> K;
  vec<pair<int, int>> A;

  int n = 0;
  for(int i = 0; i < N; i++){
    int next;
    cin >> next;
    A.push_back(make_pair(i, next-1));
  }
  DEBUG show_vec(A);
  vec<int> move;
  int curr = 0;
  while(true){
    int next = -1;
    for(int i = 0; i < A.size(); i++){
      if(A[i].first == curr){
        next = A[i].second;
        A.erase(A.begin() + i);
        break;
      }
    }
    move.push_back(curr);
    DEBUG LINE;
    if(next == -1){
      break;
    }else{
      curr = next;
    }
  }
  DEBUG LINE;
  int loop_first_val = move[move.size()-1];//.second;
  DEBUG cout << "loop_first_val : " << loop_first_val << endl;
  move.resize(move.size()-1);
  int loop_first_point;
  for(int i = 0; i < move.size(); i++){
    if(move[i] == loop_first_val){
      loop_first_point = i;
      break;
    }
  }
  DEBUG cout << "loop_first_point : " << loop_first_point << endl;

  if(K < move.size()){
    cout << move[K]+1 << endl;
  }else{
    int sift = (K-loop_first_point) % (move.size()-loop_first_point);
    cout << move[loop_first_point + sift]+1 << endl;
  }
  DEBUG show_vec(move);


  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:9: error: 'show_vec' was not declared in this scope
   43 |   DEBUG show_vec(A);
      |         ^~~~~~~~
a.cc:82:9: error: 'show_vec' was not declared in this scope
   82 |   DEBUG show_vec(move);
      |         ^~~~~~~~
Language: C++

/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
#include <show_vec.hh>


#define DEBUG  if(false)

using namespace std;

using ll = long long;
#define LINE printf("LINE : %d\n", __LINE__);
#define loop(i, n) for(i = 0; i < n; i++)
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  int N;
  ll K;
  cin >> N >> K;
  vec<pair<int, int>> A;

  int n = 0;
  for(int i = 0; i < N; i++){
    int next;
    cin >> next;
    A.push_back(make_pair(i, next-1));
  }
  DEBUG show_vec(A);
  vec<int> move;
  int curr = 0;
  while(true){
    int next = -1;
    for(int i = 0; i < A.size(); i++){
      if(A[i].first == curr){
        next = A[i].second;
        A.erase(A.begin() + i);
        break;
      }
    }
    move.push_back(curr);
    DEBUG LINE;
    if(next == -1){
      break;
    }else{
      curr = next;
    }
  }
  DEBUG LINE;
  int loop_first_val = move[move.size()-1];//.second;
  DEBUG cout << "loop_first_val : " << loop_first_val << endl;
  move.resize(move.size()-1);
  int loop_first_point;
  for(int i = 0; i < move.size(); i++){
    if(move[i] == loop_first_val){
      loop_first_point = i;
      break;
    }
  }
  DEBUG cout << "loop_first_point : " << loop_first_point << endl;

  if(K < move.size()){
    cout << move[K]+1 << endl;
  }else{
    int sift = (K-loop_first_point) % (move.size()-loop_first_point);
    cout << move[loop_first_point + sift]+1 << endl;
  }
  DEBUG show_vec(move);


  return 0;
}


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

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i = 0;i < (n); ++i)

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

	ll move=0;
	vector<ll>move_point_count(n, 0);
	vector<ll>obserb;
	vector<ll>obserb2;
	ll obserb_size = 0, obserb2_size = 0;

	while (true) {
		move_point_count.at(move)++;
		if (move_point_count.at(move) == 2) {
			break;
		}
		obserb.push_back = move;
		obserb_size++;
		move = a.at(move)-1;
	}
	ll move_memo = move;
	while (true) {

		obserb2.push_back = move;
		obserb2_size++;
		move = a.at(move) - 1;
		if (move_memo == move)break;
	}
	ll obserber = obserb_size - obserb2_size;
	if (obserber == 0)cout << obserb.at(k % obserb_size) << endl;
	else if (k <= obserber)cout << obserb.at(obserber) << endl;
	else {
		k -= obserber;
		cout << obserb2.at(k % obserb2_size) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:24: error: invalid use of member function 'std::vector<long long int>::push_back' (did you forget the '()' ?)
   29 |                 obserb.push_back = move;
      |                 ~~~~~~~^~~~~~~~~
a.cc:36:25: error: invalid use of member function 'std::vector<long long int>::push_back' (did you forget the '()' ?)
   36 |                 obserb2.push_back = move;
      |                 ~~~~~~~~^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ll N,K;
  cin>>N>>K;
  ll a[i];
  bool judge[N];
  ll count=0,place=1;
  for(int i=0;i<N;i++){
    cin>>a[i];
    judge[i]=false;
  }
  judge[0]=true;
  while(true){
    place=a[place-1];
    count++;
    if(judge[place-1]){
      ll rand=a[place-1];
      break;
    }
    judge[a[place-1]]=true;
  }
  ll a=count;
  count=0;
  for(int i=0;i<N;i++){
    judge[i]=false;
  }
  place=rand;
  while(true){
    place=a[place-1];
    count++;
    if(judge[place-1]){
      break;
    }
    judge[a[place-1]]=true;
  }
  ll b=count;
  
  ll T=(K-a)%b;
  place=rand;
  for(int i=0;i<T;i++){
    place=a[place-1];
  }
  cout<<place<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:8: error: 'i' was not declared in this scope
    7 |   ll a[i];
      |        ^
a.cc:11:10: error: 'a' was not declared in this scope
   11 |     cin>>a[i];
      |          ^
a.cc:16:11: error: 'a' was not declared in this scope
   16 |     place=a[place-1];
      |           ^
a.cc:29:9: error: invalid conversion from 'int (*)() noexcept' to 'long long int' [-fpermissive]
   29 |   place=rand;
      |         ^~~~
      |         |
      |         int (*)() noexcept
a.cc:31:12: error: invalid types 'long long int[long long int]' for array subscript
   31 |     place=a[place-1];
      |            ^
a.cc:36:12: error: invalid types 'long long int[long long int]' for array subscript
   36 |     judge[a[place-1]]=true;
      |            ^
a.cc:41:9: error: invalid conversion from 'int (*)() noexcept' to 'long long int' [-fpermissive]
   41 |   place=rand;
      |         ^~~~
      |         |
      |         int (*)() noexcept
a.cc:43:12: error: invalid types 'long long int[long long int]' for array subscript
   43 |     place=a[place-1];
      |            ^