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

#include <bits/stdc++.h>
#define rep(i,n) for (long long i=0;i < (n); ++i)
using namespace std;
using ll = long long;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}


int main() {
  // ll n,m,x,k=0,sum=0,a=0,b=0,c=0,d=0,ans=10000000,index=1,index_0=1,index_ans=1;
  ll MOD = 1000000007;
  ll INF = 1LL << 60;
  ll C[100001],A[200002],R[200002]={0},O[100001];
  string S="",T="",U="";
  ll n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  nit 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 -= l;
    k %= c;
    cout << s[l+K] << endl;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:3: error: 'nit' was not declared in this scope; did you mean 'int'?
   25 |   nit c = 1,l = 0;
      |   ^~~
      |   int
a.cc:33:5: error: 'c' was not declared in this scope
   33 |     c = s.size() - ord[v];
      |     ^
a.cc:34:5: error: 'l' was not declared in this scope
   34 |     l = ord[v];
      |     ^
a.cc:36:26: error: expected primary-expression before '<' token
   36 |   if(k<1) cout << s[k] <<<endl;
      |                          ^
a.cc:38:10: error: 'l' was not declared in this scope
   38 |     k -= l;
      |          ^
a.cc:39:10: error: 'c' was not declared in this scope
   39 |     k %= c;
      |          ^
a.cc:40:17: error: 'K' was not declared in this scope
   40 |     cout << s[l+K] << endl;
      |                 ^
a.cc:42:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (long long i=0;i < (n); ++i)
using namespace std;
using ll = long long;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}


int main() {
  // ll n,m,x,k=0,sum=0,a=0,b=0,c=0,d=0,ans=10000000,index=1,index_0=1,index_ans=1;
  ll MOD = 1000000007;
  ll INF = 1LL << 60;
  ll C[100001],A[200002],R[200002]={0},O[100001];
  string S="",T="",U="";
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  nit 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 -= l;
    k %= c;
    cout << s[l+K] << endl;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:10: error: 'n' was not declared in this scope
   18 |   cin >> n >> k;
      |          ^
a.cc:18:15: error: 'k' was not declared in this scope
   18 |   cin >> n >> k;
      |               ^
a.cc:24:3: error: 'nit' was not declared in this scope; did you mean 'int'?
   24 |   nit c = 1,l = 0;
      |   ^~~
      |   int
a.cc:32:5: error: 'c' was not declared in this scope
   32 |     c = s.size() - ord[v];
      |     ^
a.cc:33:5: error: 'l' was not declared in this scope
   33 |     l = ord[v];
      |     ^
a.cc:35:26: error: expected primary-expression before '<' token
   35 |   if(k<1) cout << s[k] <<<endl;
      |                          ^
a.cc:37:10: error: 'l' was not declared in this scope
   37 |     k -= l;
      |          ^
a.cc:38:10: error: 'c' was not declared in this scope
   38 |     k %= c;
      |          ^
a.cc:39:17: error: 'K' was not declared in this scope
   39 |     cout << s[l+K] << endl;
      |                 ^
a.cc:41:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (long long i=0;i < (n); ++i)
using namespace std;
using ll = long long;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}


int main() {
  ll n,m,x,k=0,sum=0,a=0,b=0,c=0,d=0,ans=10000000,index=1,index_0=1,index_ans=1;
  ll MOD = 1000000007;
  ll INF = 1LL << 60;
  ll C[100001],A[200002],R[200002]={0},O[100001];
  string S="",T="",U="";
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  nit 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 -= l;
    k %= c;
    cout << s[l+K] << endl;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: conflicting declaration 'std::vector<int> a'
   19 |   vector<int> a(n);
      |               ^
a.cc:13:22: note: previous declaration as 'll a'
   13 |   ll n,m,x,k=0,sum=0,a=0,b=0,c=0,d=0,ans=10000000,index=1,index_0=1,index_ans=1;
      |                      ^
a.cc:20:20: error: invalid types 'll {aka long long int}[long long int]' for array subscript
   20 |   rep(i,n) cin >> a[i];
      |                    ^
a.cc:24:3: error: 'nit' was not declared in this scope; did you mean 'int'?
   24 |   nit c = 1,l = 0;
      |   ^~~
      |   int
a.cc:30:12: error: invalid types 'll {aka long long int}[int]' for array subscript
   30 |       v = a[v-1];
      |            ^
a.cc:33:5: error: 'l' was not declared in this scope
   33 |     l = ord[v];
      |     ^
a.cc:35:26: error: expected primary-expression before '<' token
   35 |   if(k<1) cout << s[k] <<<endl;
      |                          ^
a.cc:37:10: error: 'l' was not declared in this scope
   37 |     k -= l;
      |          ^
a.cc:39:17: error: 'K' was not declared in this scope
   39 |     cout << s[l+K] << endl;
      |                 ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9;


int main()
{
    int n;
    ll k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n)
    {
        cin>>a[i];
        a[i]--;
    }
    int point=0;
    ll c=0;
    map<ll,ll> cc;
    ll shuki=0;
    while(1)
    {
        if(cc[a[point]]!=0)
        {
            shuki=c-cc[a[point]];
            break;
        }
        cc[a[point]]=c;
        point=a[point];
        
        c++;
    }
    ll modd;
    if(k<shuki)
    {
        int ans=0;
        rep(i,k)
        {
            ans=a[ans];
        }
        cout<<ans;
        return ;
    }
    else
    {
        modd=(k-cc[a[point]])%shuki;
        int ans=point;
        rep(i,modd)
        {
            ans=a[ans];
        }
        //cout<<point<<endl;
        cout<<ans+1;
        return;

    }
    

}

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

#include <bits/stdc++.h>
#sefine rep(i,n) for (long long i=0;i < (n); ++i)
using namespace std;
using ll = long long;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}


int main() {
  ll n,m,x,k=0,sum=0,a=0,b=0,c=0,d=0,ans=10000000,index=1,index_0=1,index_ans=1;
  ll MOD = 1000000007;
  ll INF = 1LL << 60;
  ll C[100001],A[200002],R[200002]={0},O[100001];
  string S="",T="",U="";
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1,-1);
  nit 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 -= l;
    k %%= c;
    cout << s[l+K] << endl;
  }
  cout << ans << endl;
}

Compiler output:
a.cc:2:2: error: invalid preprocessing directive #sefine; did you mean #define?
    2 | #sefine rep(i,n) for (long long i=0;i < (n); ++i)
      |  ^~~~~~
      |  define
a.cc: In function 'int main()':
a.cc:19:15: error: conflicting declaration 'std::vector<int> a'
   19 |   vector<int> a(n);
      |               ^
a.cc:13:22: note: previous declaration as 'll a'
   13 |   ll n,m,x,k=0,sum=0,a=0,b=0,c=0,d=0,ans=10000000,index=1,index_0=1,index_ans=1;
      |                      ^
a.cc:20:7: error: 'i' was not declared in this scope
   20 |   rep(i,n) cin >> a[i];
      |       ^
a.cc:20:3: error: 'rep' was not declared in this scope
   20 |   rep(i,n) cin >> a[i];
      |   ^~~
a.cc:24:3: error: 'nit' was not declared in this scope; did you mean 'int'?
   24 |   nit c = 1,l = 0;
      |   ^~~
      |   int
a.cc:30:12: error: invalid types 'll {aka long long int}[int]' for array subscript
   30 |       v = a[v-1];
      |            ^
a.cc:33:5: error: 'l' was not declared in this scope
   33 |     l = ord[v];
      |     ^
a.cc:35:26: error: expected primary-expression before '<' token
   35 |   if(k<1) cout << s[k] <<<endl;
      |                          ^
a.cc:37:10: error: 'l' was not declared in this scope
   37 |     k -= l;
      |          ^
a.cc:38:8: error: expected primary-expression before '%=' token
   38 |     k %%= c;
      |        ^~
a.cc:39:17: error: 'K' was not declared in this scope
   39 |     cout << s[l+K] << endl;
      |                 ^
Language: C++

#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=998244353;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int d=60;
const int MAX_N=200005;
int to[dig][MAX_N]; //to[i][j] jから2^i先の頂点

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,k;
  cin >> n >> k;
  vector<int>a(n);
  rep(i,n){
    cin >> to[0][i];
    to[0][i]--;
  }
  rep(i,d-1){
    rep(j,n){
      to[i+1][j]=to[i][to[i][j]];
    }
  }
  int v=0;
  for(int i=d-1;i>=0;i--){
    ll l=1ll<<i;
    if(l<=k){
      v=to[i][v];
      k-=l;
    }
  }
  cout << v+1 << endl;
  return 0;     
}


Compiler output:
a.cc:28:8: error: 'dig' was not declared in this scope; did you mean 'div'?
   28 | int to[dig][MAX_N]; //to[i][j] jから2^i先の頂点
      |        ^~~
      |        div
a.cc: In function 'int main()':
a.cc:38:12: error: 'to' was not declared in this scope; did you mean 'tm'?
   38 |     cin >> to[0][i];
      |            ^~
      |            tm
a.cc:43:7: error: 'to' was not declared in this scope; did you mean 'tm'?
   43 |       to[i+1][j]=to[i][to[i][j]];
      |       ^~
      |       tm
a.cc:50:9: error: 'to' was not declared in this scope; did you mean 'tm'?
   50 |       v=to[i][v];
      |         ^~
      |         tm
Language: C++

#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=998244353;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int dig=60;
const int MAX_N=200005;
int to[dig][MAX_N]; //to[i][j] jから2^i先の頂点

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n,k;
  cin >> n >> k;
  vector<int>a(n);
  rep(i,n){
    cin >> to[0][i];
    to[0][i]--;
  }
  rep(i,d-1){
    rep(j,n){
      to[i+1][j]=to[i][to[i][j]];
    }
  }
  int v=0;
  for(int i=d-1;i>=0;i--){
    ll l=1ll<<i;
    if(l<=k){
      v=to[i][v];
      k-=l;
    }
  }
  cout << v+1 << endl;
  return 0;     
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:9: error: 'd' was not declared in this scope
   41 |   rep(i,d-1){
      |         ^
a.cc:3:49: note: in definition of macro 'rep'
    3 | #define rep(i,n)for(long long i=0;i<(long long)(n);i++)
      |                                                 ^
a.cc:47:13: error: 'd' was not declared in this scope
   47 |   for(int i=d-1;i>=0;i--){
      |             ^
Language: C++

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll n, k;
ll t[200005];
bool f[200005];
int ct[200005];

int main(){
    cin >> n >> k;
    FOR(i,1,n+1){
        cin >> t[i];
    }
    ll s=1;
    REP(i,n)
    {
        if(f[s])break;
        else
        {
            f[s]=true;
            s=t[s];
        }
    }
    ll c=1;
    ll g=t[s];
    REP(i,n){
        if(g==s)break;
        else
        {
            g=t[g];
            c++;
        }
    }
    g = 1;
    ll o=0;
    REP(i,n)
    {
        if(g==s)break;
        g=t[g];
        o++;
    }
    ll b;
    if(o>k)
    {
        s=1;
        b=t;
    }
    else if(o==k)
    {
        cout << s << endl;
    }
    else{ k-=o;
    b = k%c;
    }
    REP(i,b)
    {
        s=t[s];
    }
    cout << s << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:11: error: invalid conversion from 'll*' {aka 'long long int*'} to 'll' {aka 'long long int'} [-fpermissive]
   65 |         b=t;
      |           ^
      |           |
      |           ll* {aka long long int*}
Language: C++

vector<ll> memo;
vector<ll> done;
ll d = 0;
ll dfs(ll u, ll v)
{
    if (done[u] != 0)
    {
        d = v;
        return u; //繰り返しのスタートがu;その時v回目の到着だった。
    }
    else
    {

        memo[u] = v;
        done[u] = 1;
        return dfs(to[u][0], v + 1);
    }
}
int main()
{
    ll n, k;
    cin >> n >> k;
    memo.resize(n, 0);
    done.resize(n, 0);
    rep(i, n)
    {
        ll a = 0;
        cin >> a;
        a--;
        to[i].push_back(a);
    }
    ll b = 0;
    b = dfs(0, 0); //それぞれの頂点に何回テレポートしたらいけるかを記録する。最終的に0に戻ってきたら終了
    ll c = 0;
    c = d - memo[b]; //これが周期。
    ll h = 0;
    h = (k - memo[b]) % c + memo[b];
    rep(i, n)
    {
        if (memo[i] == h)
        {
            cout << i + 1 << endl;
            break;
        }
    }
}

Compiler output:
a.cc:1:1: error: 'vector' does not name a type
    1 | vector<ll> memo;
      | ^~~~~~
a.cc:2:1: error: 'vector' does not name a type
    2 | vector<ll> done;
      | ^~~~~~
a.cc:3:1: error: 'll' does not name a type
    3 | ll d = 0;
      | ^~
a.cc:4:1: error: 'll' does not name a type
    4 | ll dfs(ll u, ll v)
      | ^~
a.cc: In function 'int main()':
a.cc:21:5: error: 'll' was not declared in this scope
   21 |     ll n, k;
      |     ^~
a.cc:22:5: error: 'cin' was not declared in this scope
   22 |     cin >> n >> k;
      |     ^~~
a.cc:22:12: error: 'n' was not declared in this scope
   22 |     cin >> n >> k;
      |            ^
a.cc:22:17: error: 'k' was not declared in this scope
   22 |     cin >> n >> k;
      |                 ^
a.cc:23:5: error: 'memo' was not declared in this scope
   23 |     memo.resize(n, 0);
      |     ^~~~
a.cc:24:5: error: 'done' was not declared in this scope
   24 |     done.resize(n, 0);
      |     ^~~~
a.cc:25:9: error: 'i' was not declared in this scope
   25 |     rep(i, n)
      |         ^
a.cc:25:5: error: 'rep' was not declared in this scope
   25 |     rep(i, n)
      |     ^~~
a.cc:32:7: error: expected ';' before 'b'
   32 |     ll b = 0;
      |       ^~
      |       ;
a.cc:33:5: error: 'b' was not declared in this scope
   33 |     b = dfs(0, 0); //それぞれの頂点に何回テレポートしたらいけるかを記録する。最終的に0に戻ってきたら終了
      |     ^
a.cc:33:9: error: 'dfs' was not declared in this scope
   33 |     b = dfs(0, 0); //それぞれの頂点に何回テレポートしたらいけるかを記録する。最終的に0に戻ってきたら終了
      |         ^~~
a.cc:34:7: error: expected ';' before 'c'
   34 |     ll c = 0;
      |       ^~
      |       ;
a.cc:35:5: error: 'c' was not declared in this scope
   35 |     c = d - memo[b]; //これが周期。
      |     ^
a.cc:35:9: error: 'd' was not declared in this scope
   35 |     c = d - memo[b]; //これが周期。
      |         ^
a.cc:36:7: error: expected ';' before 'h'
   36 |     ll h = 0;
      |       ^~
      |       ;
a.cc:37:5: error: 'h' was not declared in this scope
   37 |     h = (k - memo[b]) % c + memo[b];
      |     ^
Language: C++

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll n, k;
ll t[200005];
bool f[200005];
int ct[200005];

int main(){
    cin >> n >> k;
    FOR(i,1,n+1){
        cin >> t[i];
    }
    ll s=1;
    REP(i,n)
    {
        if(f[s])break;
        else
        {
            f[s]=true;
            s=t[s];
        }
    }
    ll c=1;
    ll g=t[s];
    REP(i,n){
        if(g==s)break;
        else
        {
            g=t[g];
            c++;
        }
    }
    g = 1;
    ll t=0;
    REP(i,n)
    {
        if(g==s)break;
        g=t[g];
        t++;
    }
    ll b;
    if(t>k)
    {
        s=1;
        b=t;
    }
    else if(t==k)
    {
        cout << s << endl;
    }
    else{ k-=t;
    b = k%c;
    }
    REP(i,b)
    {
        s=t[s];
    }
    cout << s << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:58:12: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   58 |         g=t[g];
      |            ^
a.cc:76:12: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   76 |         s=t[s];
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(i=0;i<N;++i)

int main(){
  ll i,now=0,N,K;
  cin>>N>>K;
  vector<ll> g(N),loop;
  rep(i,N){
    cin>>g[i];
    --g[i];
  }
  set<ll> se;
  while(se.insert(now).second&&K--){
    now=g[now];
  }
  if(K<=0){
    cout<<now+1<<endl;
    return 0;
  }
  se.clear();
  while(se.insert(now).second){
    loop.eb(now);
    now=g[now];
  }
  cout<<loop[K%loop.size()]+1<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:10: error: 'class std::vector<long long int>' has no member named 'eb'
   24 |     loop.eb(now);
      |          ^~
Language: C

#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define N 200010

int main() {
	int n, a[N], b[N] = { 0 }, c[N] = { 0 }; long long k;
	scanf("%d %lld", &n, &k);
	Rep(i, 1, n + 1)scanf("%d", &a[i]);
	int ch = 1, start, end;
	Rep(i, 1, N+10) {
		if (b[ch]!=0){ start = b[ch]; end = i; break; }
		b[ch] += i;
		ch = a[ch];
    }
	c[0]=ch;
	Rep(i,1,end-start+1) {
		c[i] = a[ch];
		ch = a[ch];
	}
	if (k<=start) {
		ch=1;
		rep(i,K) {
			ch = a[ch];
		}
		printf("%d",ch);
	}
	else if(end-start==1)printf("%d", ch);
	else{
		k++;
		k = k-start;
		k = k%(end-start);
		printf("%d",c[k]);
	}
}

Compiler output:
main.c: In function 'main':
main.c:23:23: error: 'K' undeclared (first use in this function)
   23 |                 rep(i,K) {
      |                       ^
main.c:2:46: note: in definition of macro 'Rep'
    2 | #define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
      |                                              ^
main.c:23:17: note: in expansion of macro 'rep'
   23 |                 rep(i,K) {
      |                 ^~~
main.c:23:23: note: each undeclared identifier is reported only once for each function it appears in
   23 |                 rep(i,K) {
      |                       ^
main.c:2:46: note: in definition of macro 'Rep'
    2 | #define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
      |                                              ^
main.c:23:17: note: in expansion of macro 'rep'
   23 |                 rep(i,K) {
      |                 ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(i=0;i<N;++i)

int main(){
  ll i,now=0,N,K;
  cin>>N>>K;
  vector<ll> g(N),loop;
  rep(i,N){
    cin>>g[i];
    --g[i];
  }
  set<ll> se;
  while(se.insert(now).second&&K--){
    now=g[now];
  }
  if(K<=0){
    print(i+1);
    return 0;
  }
  se.clear();
  while(se.insert(now).second){
    ch.eb(now);
    now=g[now];
  }
  cout<<ch[K%ch.size()]+1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: 'print' was not declared in this scope; did you mean 'rint'?
   19 |     print(i+1);
      |     ^~~~~
      |     rint
a.cc:24:5: error: 'ch' was not declared in this scope
   24 |     ch.eb(now);
      |     ^~
a.cc:27:9: error: 'ch' was not declared in this scope
   27 |   cout<<ch[K%ch.size()]+1<<endl;
      |         ^~
Language: C

#include <stdio.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define N 200010

int main() {
	int n, a[N], b[N] = { 0 }, c[N] = { 0 }; long long k;
	scanf("%d %lld", &n, &k);
	Rep(i, 1, n + 1)scanf("%d", &a[i]);
	int ch = 1, start, end;
	Rep(i, 1, N+10) {
		if (b[ch]!=0){ start = b[ch]; end = i; break; }
		b[ch] += i;
		ch = a[ch];
    }
	c[0]=ch;
	Rep(i,1,end-start+1) {
		c[i] = a[ch];
		ch = a[ch];
	}
	if (k<=start) {
		ch=1;
      	rep(i,K)ch = a[ch];
		printf("%d",ch);
	}
	else if(end-start==1)printf("%d", ch);
	else{
		k++;
		k = k-start;
		k = k%(end-start);
		printf("%d",c[k]);
	}
}

Compiler output:
main.c: In function 'main':
main.c:23:15: error: 'K' undeclared (first use in this function)
   23 |         rep(i,K)ch = a[ch];
      |               ^
main.c:2:46: note: in definition of macro 'Rep'
    2 | #define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
      |                                              ^
main.c:23:9: note: in expansion of macro 'rep'
   23 |         rep(i,K)ch = a[ch];
      |         ^~~
main.c:23:15: note: each undeclared identifier is reported only once for each function it appears in
   23 |         rep(i,K)ch = a[ch];
      |               ^
main.c:2:46: note: in definition of macro 'Rep'
    2 | #define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
      |                                              ^
main.c:23:9: note: in expansion of macro 'rep'
   23 |         rep(i,K)ch = a[ch];
      |         ^~~
Language: C

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

int main(){
long long int n,k,d,e,f;
  cin>>n>>k;
   vector<long long> c(n+1);
  bool finished=false;
  c.at(0)=1;
  vector<long long> a(n);
  for(long long i=0;i<n;i++){
cin>>a.at(i);
  }
for(long long i=1;i<n+1;i++){
  c.at(i)=a.at(c.at(i-1)-1);
  for(long long j=0;j<i;j++){
if(c.at(j)==c.at(i)){
 d=i-j;
  e=j;
  finished=true;
  break;
}
  }
  if(finished==true){
break;
  }
}
if(k<=e){
cout<<c.at(k)<<endl;
}else{
  f=(k-e)%d;
  cout<<c.at(e+f)<<endl;
}
}
  
  


  


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

#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n;
	long k;
	int *a;
	int *visited;
	int *x;
	scanf("%d", &n);
	scanf("%ld", &k);
	a = (int *)malloc(sizeof(int) * n);
	visited = (int *)malloc(sizeof(int) * n);
	x = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
		visited[i] = 0;
		x[i] = 0;
	}
	int tmp_city = 1;
	int j = 0;
	while(visited[tmp_city-1] == 0){
		visited[tmp_city-1] = 1;
		x[j] = tmp_city;
		j++;
		tmp_city = a[tmp_city-1];
	}
	
	int l = 0;
	while(x[l] != tmp_city){
		l++;
	}

	if(k => l){
		k = (k-l)%(j-l);
		printf("%d\n", x[l+k]);
	}
	else{
		printf("%d\n", x[k]);
	}
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:33:15: error: expected expression before '>' token
   33 |         if(k => l){
      |               ^
Language: C++

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

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return 1;
  }
  else {
    return 0;
  }
}

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  vector<int> r;
  int s=1;
  for (int i=0; i<k; i++){
    s=vec.at(s-1);
    if (vector_finder(vec,s)==0){
      r.push_back(s);
    }
    else{
      int x=find(r.begin(),r.end(),s);
      int mod=r.size()-x;
      int t=(k-i-1)%mod;
      cout << r.at(x+t) << endl;
      break;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
   32 |       int x=find(r.begin(),r.end(),s);
      |             ~~~~^~~~~~~~~~~~~~~~~~~~~
      |                 |
      |                 __gnu_cxx::__normal_iterator<int*, std::vector<int> >
Language: C++

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

int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++){
    cin >> A.at(i);
  }
  vector<long long> B(N), C(N);
  B = A;
  C = A;
  
  int times = 0;
  int place = 1;
  while( B.at(place - 1) != 0 ) {
    B.at(place - 1) = 0;
    place = A.at(place - 1);
    times++;
  }
  
  int times_again = 0;
  int place_again = place;
  while( C.at(place_again - 1) != 0){
    C.at(place_again - 1) = 0;
    place_again = A.at(place_again - 1);
    times_again++;
  }
  
  if (times < K){
    if(times_again == 1){
      cout << place << endl;
    }

    else{
      for(int i = 0; i < (K - times) % times_again; i++){
          place = A.at(place - 1);
      }
      cout << place << endl;
    }
  }
  
  else{
    p = 1;
    for(int i = 0; i < N; i++){
      p = A.at(p - 1);
      cout << p << endl;
    }
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:5: error: 'p' was not declared in this scope
   45 |     p = 1;
      |     ^
Language: C++

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

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return 1;
  }
  else {
    return 0;
  }
}

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  vector<int> r;
  int s=1;
  for (int i=0; i<k; i++){
    s=vec.at(s-1);
    if (vector_finder(vec,s)==0){
      r.push_back(s);
    }
    else{
      int x=find(r.begin(),r.end(),s);
      int mod=r.size()-x;
      int t=(k-i-1)%mod;
      cout << r.at(x+t) << endl;
      break;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:17: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
   31 |       int x=find(r.begin(),r.end(),s);
      |             ~~~~^~~~~~~~~~~~~~~~~~~~~
      |                 |
      |                 __gnu_cxx::__normal_iterator<int*, std::vector<int> >
Language: C++

//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    ll K; cin >> K;
    veci A(N);
    vector<bool> seen(N,false);
    int next;
    REP(i,N) {
        int a; cin >> a;
        a--;
        A[i] = a;
    }
    int ans;
    if(N >= K) {
        REP(i,K) {
            ans = A[A[i]];
        }
    } else {
        ll rest;
        int v = -1;
        REP(i,N) {
            next = A[A[i]];
            seen
        }

        ll cnt = 0;

        if(K-N == 1) {
            cout << A[next]+1 << endl;
            return 0;
        }

        int cur = next;

        REP(i,N) {
            v = A[cur];
            cur = A[next];
            cnt++;
            if(cur == next) break;
        }

        rest = (K-N)%cnt;
        REP(i,rest) {
            next = A[next];
        }
        //cout << rest << endl;
        ans = next;
        
    }
    cout << ans+1 << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: expected ';' before '}' token
   38 |             seen
      |                 ^
      |                 ;
   39 |         }
      |         ~
Language: C++

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

int tel();

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> root(N);
  for(int i=0;i<N;i++){
    cin >> root.at(i);
  }
  
  int r = 1;
  for(int j=0;j<K;j++){
    tel(r,N,root,j);
  }
  
  cout << r <<endl;

}

int tel(int &r,int &N,vector<int> &root,int j){
  for(int i=1; i<(N+1) ;i++){
    if(r == i){
      r =  root.at(i-1);
    }
  }
  return r; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:8: error: too many arguments to function 'int tel()'
   16 |     tel(r,N,root,j);
      |     ~~~^~~~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int tel();
      |     ^~~
Language: C++

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

int main(){
	int N; cin >> N;
  	int64_t K; cin >> K;
  	vector<int> tele(N);
  	for(int i=0 ; i<N; i++){
    	cin >> tele.at(i);
    }
  	bool loop=false;
  	int place=1;
  	int cycle = 0;
  	vector<int> mapp;
  	mapp.at(0)=1;
  	while(true){
    	place = tele.at(place-1);
      	cycle++;
      	mapp.at(cycle)=place;
      	if(place ==1){break;}
      	else(mapp.at(cycle-1) == mapp.at(cycle)){
          loop = true;
          break;
        }
      	
    }
  	if(loop && K >= cycle){cout << mapp.at(cycle) << endl;}
  	else if(loop){cout << mapp.at(K) << endl;}
  	else{
      K%=cycle;
      cout << mapp.at(K) << endl;
    }
  
  	
      	
  	
  	
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:49: error: expected ';' before '{' token
   21 |         else(mapp.at(cycle-1) == mapp.at(cycle)){
      |                                                 ^
      |                                                 ;
Language: C++

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

int N,K;
vector<int> V(N);

//int move(int n, int k){
//  if(k == 0) return V.at(n);
//  
//  k--;
//  return move(V.at(n),k);
//}


int main(){
  cin >>N >>K;
 
  for(int i=0; i<N; i++){
    cin >> V.at(i); 
    //V.at(i)--;
  }
   
  move(0,K);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:7: error: no matching function for call to 'move(int, int&)'
   24 |   move(0,K);
      |   ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/move.h:137:5: note: candidate: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
  137 |     move(_Tp&& __t) noexcept
      |     ^~~~
/usr/include/c++/14/bits/move.h:137:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: candidate: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
  675 |     move(_II __first, _II __last, _OI __result)
      |     ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
  353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note:   candidate expects 4 arguments, 2 provided
Language: C++

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

int main(){
	int N; cin >> N;
  	int64_t K; cin >> K;
  	vector<int> tele(N);
  	for(int i=0 ; i<N; i++){
    	cin >> tele.at(i);
    }
  	bool loop=false;
  	int place=1;
  	int cycle = 0;
  	vector<int> mapp;
  	mapp.at(0)=1;
  	while(true){
    	place = tele.at(place-1);
      	cycle++;
      	mapp.at(cycle)=place;
      	if(place ==1){break;}
      	else(mapp[cycle-1] == mapp[cycle]){
          loop = true;
          break;}
      	
    }
  	if(loop && K >= cycle){cout << mapp[cycle] << endl;}
  	else if(loop){cout << mapp[K] << endl;}
  	else{
      K%=cycle;
      cout << mapp.at(K) << endl;
    }
  
  	
      	
  	
  	
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:43: error: expected ';' before '{' token
   21 |         else(mapp[cycle-1] == mapp[cycle]){
      |                                           ^
      |                                           ;
Language: C++

#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 1LL << 20;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    int N;
    ll K;
    cin >> N;
    cin >> K;

    int A[200000];
    for(int i = 0l; i < N; i++){
        cin >> A[i];
        A[i]--;
    }

    int l = 0;
    ll c = 1;
    int T[200000]={0};
    T[l] = c++;
    for(;;){
        l = A[l];
        if(T[l] != 0){
            break;
        }
        T[l] = c++;
    }
    c--;

    int begin = T[l] - 1;

    k -= begin;
    if(K <= 0){
        int v = 0;
        for(int i = 0; i < K; i++){
            v = A[v];
        }
        cout << v + 1 << endl; 
        return;
    }
    ll n = (c-begin == 0) ? K : K % (c-begin);
    int v = 0;
    for(int i = 0; i < n + begin; i++){
        v = A[v];
    }

    cout << v + 1 << endl; 
}


Compiler output:
a.cc: In function 'void execute()':
a.cc:50:5: error: 'k' was not declared in this scope
   50 |     k -= begin;
      |     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    ll N,K;
    cin>>N>>K;
    VL A(N);
    ll ans=0;
    rep(i,0,N){
        cin>>A[i];
    }
    //roop省く
    ll id=0;
    VL x(2*N,0):
    rep(j,0,(2*N+1)){
        ans=A[id]-1;
        x[j]=ans;
    }
    rep(j,0,(2*N+1)){
        rep(k,0,j+1){
            if(x[j]==x[k])id=j;
        }
    }
    ll SID=id;
    ll EID;
    rep(id,0,(2*N+1)){
        if(x[SID]==x[id])EID=id;
    }
    ll n=EID-SID+1;
    K=K-((K/n)*(n-1)+SID);
    id=EID+1;
    rep(id,0,(K+1)){
        ans=A[id]-1;
        id=ans;
    }

    cout<<A[ans]+1;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:16: error: expected ',' or ';' before ':' token
   18 |     VL x(2*N,0):
      |                ^
a.cc:19:9: error: 'j' was not declared in this scope
   19 |     rep(j,0,(2*N+1)){
      |         ^
a.cc:4:52: note: in definition of macro 'rep'
    4 | #define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
      |                                                    ^
Language: C

#include <bits/stdc++.h>

using namespace std;

#define data_type long long

#define endl "\n"

int main()

{

    //ios_base::sync_with_stdio(false);

    //cin.tie(NULL);

    data_type n,k,counter,x=0;

    cin>>n>>k;

    counter=k;

    vector<data_type>vc(n),ans;

    for(auto &i:vc)

        cin>>i,--i;

    bitset<200001> is_visited;

    while(!is_visited[x] && counter--)

        {

            ans.push_back(x+1);

            is_visited[x]=true;

            x=vc[x];

        }

    if(counter==-1)

        return cout<<x<<endl,0;

    data_type in=distance(ans.begin(),find(ans.begin(),ans.end(),x+1));

    cout<<ans[(k-in+1)%(ans.size()-in+1)]<<endl;

    return 0;

}



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

#include <bits/stdc++.h>

using namespace std;

#define data_type long long

#define endl "\n"

int main()

{

    //ios_base::sync_with_stdio(false);

    //cin.tie(NULL);

    data_type n,k,counter,x=0;

    cin>>n>>k;

    counter=k;

    vector<data_type>vc(n),ans;

    for(auto &i:vc)

        cin>>i,--i;

    bitset<200001> is_visited;

    while(!is_visited[x] && counter--)

        {

            ans.push_back(x+1);

            is_visited[x]=true; 

            x=vc[x];

        }

    if(counter==-1)

        return cout<<x<<endl,0;

    int in=distance(ans.begin(),find(ans.begin(),ans.end(),x+1));

    cout<<ans[(k-in+1)%(ans.size()-in+1)]<<endl;

    return 0;

}

#include <bits/stdc++.h>

using namespace std;

#define data_type long long

#define endl "\n"

int main()

{

    //ios_base::sync_with_stdio(false);

    //cin.tie(NULL);

    data_type n,k,counter,x=0;

    cin>>n>>k;

    counter=k;

    vector<data_type>vc(n),ans;

    for(auto &i:vc)

        cin>>i,--i;

    bitset<200001> is_visited;

    while(!is_visited[x] && counter--)

        {

            ans.push_back(x+1);

            is_visited[x]=true;

            x=vc[x];

        }

    if(counter==-1)

        return cout<<x<<endl,0;

    data_type in=distance(ans.begin(),find(ans.begin(),ans.end(),x+1));

    cout<<ans[(k-in+1)%(ans.size()-in+1)]<<endl;

    return 0;

}

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

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

int one_loop(int n)
{
    if(tele[n] == 1)return 1;
    if(tele[n] != 1)return one_loop(tele[n]) + 1;
}

int main()
{
    int N;
    long long K;
    cin>>N>>K;

    vector<int> tele(N);
    for(int i = 0; i<N; i++)
    {
        cin>>tele[i];
    }

    int loop1 = one_loop(1);
    cout<<"1ループは"<<loop1<<endl;
    long long move = (long long)K % loop1;

    int ans = 1;
    for(int i = 0; i<move; i++)
    {
        ans = tele[ans];
    }

    cout<<ans<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int one_loop(int)':
a.cc:6:8: error: 'tele' was not declared in this scope
    6 |     if(tele[n] == 1)return 1;
      |        ^~~~
a.cc:7:8: error: 'tele' was not declared in this scope
    7 |     if(tele[n] != 1)return one_loop(tele[n]) + 1;
      |        ^~~~
Language: C++

#include<iostream>
#include<bits/stdc++.h>

using namespace std;

int main()
{
    long long int n , k , i;
    cin>>n>>k;
    vector<long long int>v;
    long long int a[n+1] , b[n+1]={0} , c = 0 , ind ,p=0 ;
    for( i = 1 ; i <=n ; i++)cin>>a[i];
    b[1]=1;
    i = 1;
    v.push_back(1);
    while(b[i]!=2)
    {   
        c++; 
        i = a[i];
        v.push_back(i);
        ind = i;
        b[i]++;
    }

    for( i = 1 ; i <=ind ;i++)if(b[i]==1)p++;
    
    long long int l=(k-p)%c
    cout<<a[l]<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: expected ',' or ';' before 'cout'
   28 |     cout<<a[l]<<endl;
      |     ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <map>

using namespace std;

int N;
long long K;

int main()
{
    cin>>N>>K;
    vector<int> A;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        A.push_back(a-1);
    }
    if(A[0]==0){
        cout << 1 << endl;
        return 0;
    }
    
    vector<int> B;
    map<int,int> Flag;
    Flag[0]=1;
    int next=A[0];
    while(Flag[next]!=1){
        Flag[next]=1;
        B.push_back(next);
        next=A[next];
    }
    int n=0;
    for(auto b : B){
        if(b==next){
            break;
        }
        n++;
    }
    if(A[next]==next){
        cout << next + a << endl;
        return 0; 
    }
    long long l;
    if(next==0){
        l = B.size()+1;
        n = 0;
        cout << B[K%l-1]+1 << endl;
    }else{
        l = B.size()-n;
        cout << B[n+(K-n-1)%l]+1 << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:24: error: 'a' was not declared in this scope
   40 |         cout << next + a << endl;
      |                        ^
Language: C

#include<stdio.h>

int main(void){
  int n;
  long k;
  scanf("%d%ld", &n, &k);

  int a[n+1];
  int done[n+1];
  a[0] = 0;
  done[0] = -1;
  for(int i = 1; i <= n; i++){
    scanf("%d", &a[i]);
    done[i] = 0;
  }

  long outCycle = 0;
  long cycle = 0;
  long startCycle = 0;

  int now = 1;
  int next = 0;
  done[now] = 1;

  // printf("%d ", now);
  for(long i = 1; i <= k; i++){
    next = a[now];
    if(done[next]){
      outCycle = done[next] - 1;
      cycle = i - done[next];
      startCycle = next;
      break;
    }
    now = next;
    done[now] = i;
    // printf("-> %d ", now);
  }
  printf("%d %d %d\n", outCycle, cycle, startCycle);
  if(cycle){
    long kc = k - outCycle;
    long end = kc % cycle;
    now = now[startCycle];
    for(long i = 0; i < end; i++){
      now = a[now];
    }
  }
  // printf("\n");
  printf("%d\n", now);
}


Compiler output:
main.c: In function 'main':
main.c:42:14: error: subscripted value is neither array nor pointer nor vector
   42 |     now = now[startCycle];
      |              ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;

int main(){
  ll n,k;
  cin>>n>>k;
  ll a[n+1];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll town=1;
  do while(town=1){
    rep(j,k){
    town=a[town];
    }
  }
  rep(k>=n){
    k%=n;
  }
  rep(b,k){
    town=a[town];
  }
  cout<<town<<endl;
}



Compiler output:
a.cc:19:11: error: macro "rep" requires 2 arguments, but only 1 given
   19 |   rep(k>=n){
      |           ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,n) for (int (i) = 0; (i) < (n); i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:19:3: error: expected 'while' before 'rep'
   19 |   rep(k>=n){
      |   ^~~
a.cc:19:3: error: expected '(' before 'rep'
   19 |   rep(k>=n){
      |   ^~~
      |   (
a.cc:19:3: error: 'rep' was not declared in this scope
   19 |   rep(k>=n){
      |   ^~~
a.cc:19:6: error: expected ')' before '{' token
   19 |   rep(k>=n){
      |   ~~~^     ~
      |      )
a.cc:19:6: error: expected ';' before '{' token
   19 |   rep(k>=n){
      |      ^     ~
      |      ;
Language: C++

#int(input())
n,k=map(int,input().split())
aa=list(map(int,input().split()))
f=0
d={}
for i in range(1,n+1):
    d[i]=aa[i-1]
pos=1
apos=0
steps=0
l=[1]
ch=[0]*(n+1)
while(ch[pos]<1):
    apos=d[pos]
    ch[pos]+=1
    pos=apos
    steps+=1
    l.append(apos)
l.pop()

pos=l[-1]

ll=[pos]
chh=[0]*(n+1)
stepss=0
while(ch[pos]<2):
    apos=d[pos]
    ch[pos]+=1
    pos=apos
    stepss+=1
    ll.append(apos)
ll.pop()
#print(ll)  
x=k%steps
k=k-steps
print(ll[(k%stepss+)1])

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #int
    1 | #int(input())
      |  ^~~
a.cc:33:2: error: invalid preprocessing directive #print
   33 | #print(ll)
      |  ^~~~~
a.cc:2:1: error: 'n' does not name a type
    2 | n,k=map(int,input().split())
      | ^
a.cc:6:1: error: expected unqualified-id before 'for'
    6 | for i in range(1,n+1):
      | ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
using ll = long long;
using P = pair<ll, ll>;

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

    vector<ll> chk(k);
    chk.at(0) = 1;
    bool cycled = false;
    ll start;
    ll cyc;
    for (ll i = 1; i <= k; i++){
        chk.at(i) = a.at(i - 1);
        rep(j, i - 1){
            if (chk.at(j) == chk.at(i)){
                start = j;
                cyc = i - j;
                cycled = true;
                break;
            }
        }
        if (cycled == true) break;
    }

    ll ans;
    if (start < k){
        rep(i, k - 1){
            ans = a.at(i - 1);
        }
        cout << ans << endl;
    }
    else{
        ll step;
        step = (k - start) % cyc;
        ans = a.at(start + step);
        cout << ans << endl;
    }

    return 0;
} 

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

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <string>

int N;
long long K;
std::vector<int> A;
std::map<int, int> city_to_j;

int main() {
  std::cin >> N >> K;
  A.assign(N, 0);
  history.assign(N, 0);
  int current_city = 0;
  int sta_j = 0;

  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
    --A[i];
  }
  int div = 0;
  for (long long j = 0; j < K ; j++) {
    city_to_j[current_city] = j;
    current_city = A[current_city];
    if (city_to_j.count(current_city) == 1) {
      div = j - city_to_j[current_city] + 1;
      sta_j = j;
      break;
    }
  }
  for (int k = 0; k < ((K - sta_j) % div)+2; k++) {
    current_city = A[current_city];
  }
  std::cout << current_city + 1 << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:3: error: 'history' was not declared in this scope
   16 |   history.assign(N, 0);
      |   ^~~~~~~
Language: C++

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

	int a[200010];
	for(int i = 0;i < n;i++){
		cin >> a[i];
		a[i]--;
	}
	int v[200010];
	memset(v, -1, sizeof(v));
	int now = a[i];
	int cnt = 0;
	while(1){
		v[now] = cnt;
		if(k == 0){
			cout << now+1 << endl;
		}
		cnt++;
		k--;
		if(v[a[now]] != -1){
			k %= cnt;
			break; 
		}
		now = a[now];
	}
	while(1){
		if(k == 0){
			cout << now+1 << endl;
		}
		k--;
		now = a[now];
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:21: error: 'i' was not declared in this scope
   19 |         int now = a[i];
      |                     ^