Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int int64
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

vi a(200010);
vector<bool>visited(200010,0);

int looplen(int s){
    int u;
    while(1){
        if(visited[s]){u=s;break;}
        else{visited[s] = 1;s = a[s];}
    }
    int ret = 1;
    int t = a[s];
    while(t!=s){
        ret++;
        t = a[t];
    }
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    rep(i,0,n){cin>>a[i];a[i]--;}
    if(a[0]==0){cout<<1;return 0;}
    int r = k%looplen(0);
    int s = 0;
    while(r){
        s = a[s];
        r--;
    }
    cout<<s+1<<endl;
}


Compiler output:
a.cc:3:13: error: 'int64' was not declared in this scope
    3 | #define int int64
      |             ^~~~~
a.cc:4:14: note: in expansion of macro 'int'
    4 | typedef pair<int,int> P;
      |              ^~~
a.cc:3:13: error: 'int64' was not declared in this scope
    3 | #define int int64
      |             ^~~~~
a.cc:4:18: note: in expansion of macro 'int'
    4 | typedef pair<int,int> P;
      |                  ^~~
a.cc:4:21: error: template argument 1 is invalid
    4 | typedef pair<int,int> P;
      |                     ^
a.cc:4:21: error: template argument 2 is invalid
a.cc:3:13: error: 'int64' does not name a type; did you mean 'int64_t'?
    3 | #define int int64
      |             ^~~~~
a.cc:13:7: note: in expansion of macro 'int'
   13 | const int MOD = 1e9 + 7;
      |       ^~~
a.cc:3:13: error: 'int64' does not name a type; did you mean 'int64_t'?
    3 | #define int int64
      |             ^~~~~
a.cc:15:7: note: in expansion of macro 'int'
   15 | const int INF = 1e18;
      |       ^~~
a.cc:3:13: error: 'int64' was not declared in this scope
    3 | #define int int64
      |             ^~~~~
a.cc:10:19: note: in expansion of macro 'int'
   10 | #define vi vector<int>
      |                   ^~~
a.cc:18:1: note: in expansion of macro 'vi'
   18 | vi a(200010);
      | ^~
a.cc:10:22: error: template argument 1 is invalid
   10 | #define vi vector<int>
      |                      ^
a.cc:18:1: note: in expansion of macro 'vi'
   18 | vi a(200010);
      | ^~
a.cc:10:22: error: template argument 2 is invalid
   10 | #define vi vector<int>
      |                      ^
a.cc:18:1: note: in expansion of macro 'vi'
   18 | vi a(200010);
      | ^~
a.cc:3:13: error: 'int64' does not name a type; did you mean 'int64_t'?
    3 | #define int int64
      |             ^~~~~
a.cc:21:1: note: in expansion of macro 'int'
   21 | int looplen(int s){
      | ^~~
a.cc: In function 'int main()':
a.cc:3:13: error: 'int64' was not declared in this scope
    3 | #define int int64
      |             ^~~~~
a.cc:39:5: note: in expansion of macro 'int'
   39 |     int n,k;
      |     ^~~
a.cc:40:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   40 |     cin>>n>>k;
      |          ^
      |          yn
a.cc:40:13: error: 'k' was not declared in this scope
   40 |     cin>>n>>k;
      |             ^
a.cc:41:9: error: expected ';' before 'i'
   41 |     rep(i,0,n){cin>>a[i];a[i]--;}
      |         ^
a.cc:6:28: note: in definition of macro 'rep'
    6 | #define rep(i,a,n) for(int i=a;i<n;i++)
      |                            ^
a.cc:41:9: error: 'i' was not declared in this scope
   41 |     rep(i,0,n){cin>>a[i];a[i]--;}
      |         ^
a.cc:6:32: note: in definition of macro 'rep'
    6 | #define rep(i,a,n) for(int i=a;i<n;i++)
      |                                ^
a.cc:42:9: error: invalid types 'int[int]' for array subscript
   42 |     if(a[0]==0){cout<<1;return 0;}
      |         ^
a.cc:43:9: error: expected ';' before 'r'
   43 |     int r = k%looplen(0);
      |         ^
a.cc:44:9: error: expected ';' before 's'
   44 |     int s = 0;
      |         ^
a.cc:45:11: error: 'r' was not declared in this scope
   45 |     while(r){
      |           ^
a.cc:46:9: error: 's' was not declared in this scope
   46 |         s = a[s];
      |         ^
a.cc:49:11: error: 's' was not declared in this scope
   49 |     cout<<s+1<<endl;
      |           ^