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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>vec(N);
  for(int i=0;i<N;i++){
    cin>>vec(N);
  }
  int Light=1;
  bool flag=true;
  int count=0;
  for(int i=0;i<N;i++){
    count=count+1;
    Light=vec.at(Light-1);
    if(Light==2){
      flag=false;
      break;
    }
    else{
    }
  }
  if(flag==false){
    cout<<count<<endl;
  }
  else{
    cout<<-1<<endl;
  }
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: no match for call to '(std::vector<int>) (int&)'
    8 |     cin>>vec(N);
      |          ~~~^~~
Language: C++

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

int main(){
	int N;
	cin >> N;
	
	vector<int> Ass(N), Bss(N);
	
	for(int i = 0;i < N;i++){
		cin >> Ass.at(i);
	}
	
	bool flag = false;
	int cnt = 0;
	
	for(int j = 0;j < N+1;){
		int c = Ass.at(i);
		c--;
		cnt++;
		
		if(c == 1){
			flag = true;
			break;
		}
		else{
			Ass.at(c)++;
		}
		
		if(Ass.at(c)>1){
			flag = false;
			cnt = 0;
			break;
		}
	}
	
	cout << cnt << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:32: error: 'i' was not declared in this scope
   18 |                 int c = Ass.at(i);
      |                                ^
Language: C++

N=int(input())
a=[int(input()) for i in range(N)]

x=1
for i in range(N):
  if(x==2):
    print(i)
    exit()
  x=a[x-1]
print("-1")

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N=int(input())
      | ^
Language: C++

//そもそも2があるかどうか、
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N ; i++) {
    cin >> vec.at(i);
  }
  
  int count=1;
  int j=0;
  for (true) {
    if (vec.at(j)==2 || count==N+1)
      break;
    else {
      j=vec.at(j);
      count++;
    }
  }
  if (count==N+1)
    cout << -1 << endl;
  else 
    cout << count << endl;
        
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:12: error: expected ';' before ')' token
   16 |   for (true) {
      |            ^
      |            ;
a.cc:24:3: error: expected primary-expression before 'if'
   24 |   if (count==N+1)
      |   ^~
a.cc:23:4: error: expected ';' before 'if'
   23 |   }
      |    ^
      |    ;
   24 |   if (count==N+1)
      |   ~~
a.cc:24:3: error: expected primary-expression before 'if'
   24 |   if (count==N+1)
      |   ^~
a.cc:23:4: error: expected ')' before 'if'
   23 |   }
      |    ^
      |    )
   24 |   if (count==N+1)
      |   ~~
a.cc:16:7: note: to match this '('
   16 |   for (true) {
      |       ^
Language: C++

//そもそも2があるかどうか、
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N ; i++) {
    cin >> vec.at(i);
  }
  
  int count=1;
  int j=0;
  for (; j<N+1 ;) {
    if (vec.at(j)==2 || count=N)
      break;
    else {
      j=vec.at(j);
      count++;
    }
  }
  if (j=N)
    cout << -1 << endl;
  else 
    cout << count << endl;
        
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:22: error: lvalue required as left operand of assignment
   17 |     if (vec.at(j)==2 || count=N)
      |         ~~~~~~~~~~~~~^~~~~~~~
Language: C++

//そもそも2があるかどうか、
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N ; i++) {
    cin >> vec.at(i);
  }
  
  int count=1;
  int j=0;
  for (; j<N+1 ;) {
    if (vec.at(j)==2 && count=N)
      break;
    else {
      j=vec.at(j);
      count++;
    }
  }
  if (j=N)
    cout << -1 << endl;
  else 
    cout << count << endl;
        
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:22: error: lvalue required as left operand of assignment
   17 |     if (vec.at(j)==2 && count=N)
      |         ~~~~~~~~~~~~~^~~~~~~~
Language: C++

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

int main(){
  int n,a[110000];
  cin>>n;
  for(int i=1;i<n;i++) cin>>a[i];
  int t=a[1],cnt=1;
  for(int i=0;i<n;i++){
    if(t==2){ cout<<cnt; return 0 };
    t=a[t];
    cnt++;
  }
  cout<<"-1";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:34: error: expected ';' before '}' token
   10 |     if(t==2){ cout<<cnt; return 0 };
      |                                  ^~
      |                                  ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(i = 0;i < N;i++){
        cin >> a.at(i);
    }
    int button = 1;
    int count = 0;
    for (int j=0;j < N+10;j++){
        button = a.at(button - 1);
        count++;
        if(button == 2){
            cout << count << endl;
            break;
        }else if(button ==){
            cout << "-1" << endl;
            break;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'i' was not declared in this scope
    8 |     for(i = 0;i < N;i++){
      |         ^
a.cc:19:27: error: expected primary-expression before ')' token
   19 |         }else if(button ==){
      |                           ^
Language: C++

N = int(input())
A = [int(input()) for _ in range(N)]

now = 0
count = 0
while True:
    if count >= N:
        print(-1)
        break

    if now == 1:
        print(count)
        break

    now = A[now] - 1
    count += 1

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  int ans=1;
  for(;;){
    ans++;
    if(a.at(a.at(0)-1)==2){
      cout<<ans<<endl;
      return 0;
    }
    else{
      a.at(0)=a.at(a.at(0)-1);
      if(ans>=n){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: 'n' was not declared in this scope
   19 |       if(ans>=n){
      |               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++) {
    cin >> a.at(i);}
  int sum=0;
  for(int i=0;i<N;i++) {
    if(a.at(1)!=1) {
      sum=-1;
      cout << sum << endl;}
    else {if(a.at(i)!=2) {
      sum+=1;}
          else {
            cout << sum << endl;}
          }
    }
  }
}
            


Compiler output:
a.cc:21:1: error: expected declaration before '}' token
   21 | }
      | ^
Language: C++

#include <bits/stdc++>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++) {
    cin >> a.at(i);}
  int sum=0;
  for(int i=0;i<N;i++) {
    if(a.at(1)!=1) {
      sum=-1;
      cout << sum << endl;}
    else {if(a.at(i)!=2) {
      sum+=1;}
          else {
            cout << sum << endl;}
          }
    }
  }
}
            

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

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

int main() {
    int n;
    cin >> n;
    int a[n+1]={};
    for(int i=1;i<n+1;i++){
        cin >> a[i];
    }
    int num = a[1];
    int count = 1;
    for(int k=1;k<n+10;k++){
        if(a[num]==2)[
            count++;
            break;
        }
        else{
            num = a[num];
            count++;
        }
    } 
    if (count>n) cout << -1 << endl;
    else{
        cout << count << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:18: error: expected ',' before '++' token
   15 |             count++;
      |                  ^~
      |                  ,
a.cc:15:18: error: expected identifier before '++' token
   15 |             count++;
      |                  ^~
a.cc:15:20: error: expected ']' before ';' token
   15 |             count++;
      |                    ^
      |                    ]
a.cc: In lambda function:
a.cc:15:20: error: expected '{' before ';' token
a.cc: In function 'int main()':
a.cc:18:9: error: 'else' without a previous 'if'
   18 |         else{
      |         ^~~~
a.cc: At global scope:
a.cc:23:5: error: expected unqualified-id before 'if'
   23 |     if (count>n) cout << -1 << endl;
      |     ^~
a.cc:24:5: error: expected unqualified-id before 'else'
   24 |     else{
      |     ^~~~
a.cc:27:1: error: expected declaration before '}' token
   27 | }
      | ^
Language: C++

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++)
    cin >> a.at(i);
  
  int tmp = 1;
  int cnt = 0;
  while (;;) {
    tmp = a.at(tmp);
    cnt++;
    if (tmp == 1 || tmp == 2) break;
  }
  
  if (tmp == 2) cout << cnt << endl;
  else cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:10: error: expected primary-expression before ';' token
   14 |   while (;;) {
      |          ^
a.cc:14:10: error: expected ')' before ';' token
   14 |   while (;;) {
      |         ~^
      |          )
a.cc:14:12: error: expected primary-expression before ')' token
   14 |   while (;;) {
      |            ^
Language: C++

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

int main(){

    int n;
    int count;
    int light=1;
    bool able=false;
    vector<int> a(10000);

    cin>>n;

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

    for(int i=0;i<n;i++){
        
        light=a.at(light-1);
        if(light==2) able=true;
        count=i+1;
        if(able) break;

    }

    if(able) cout<<count<<endl;
    else cout<<-1<<endl;







    return 0;
}

Compiler output:
a.cc:1:9: 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 main() {
	int N;
  	cin >> N;
  	vector<int> light(N + 1); //最初のボタン「 1 」を含めるので要素数を +1 する
	light.at(0) = 1; //最初のボタン「 1 」を要素 0番 に登録する
    int SUM = 0;　//ボタンを何回押したかカウントするための変数
  	int NEXT = 0;　//次に押すボタンの番号を表す変数
  	int flag = 0; //ボタン「 2 」が光ったかどうかを判定するための変数
  	int a;
  	for(int i = 0; i < N; i++){
   		cin >> a;
		light.at(i + 1) = a;
    }
  	for(int j = 0; j < N; j++){
      	if(light.at(NEXT) == 2){
          	flag = 1;
        	break;
        }
      	NEXT = light.at(NEXT);
      	SUM += 1;
    }
  	if(flag == 1){
    	cout << SUM << endl;
    }else{
    	cout << -1 << endl;
    }
}


Compiler output:
a.cc:9:17: error: extended character 　 is not valid in an identifier
    9 |     int SUM = 0;　//ボタンを何回押したかカウントするための変数
      |                 ^
a.cc:10:22: error: extended character 　 is not valid in an identifier
   10 |         int NEXT = 0;　//次に押すボタンの番号を表す変数
      |                      ^
a.cc: In function 'int main()':
a.cc:9:17: error: '\U00003000' was not declared in this scope
    9 |     int SUM = 0;　//ボタンを何回押したかカウントするための変数
      |                 ^~
a.cc:10:24: error: expected ';' before 'int'
   10 |         int NEXT = 0;　//次に押すボタンの番号を表す変数
      |                        ^
      |                        ;
   11 |         int flag = 0; //ボタン「 2 」が光ったかどうかを判定するための変数
      |         ~~~             
a.cc:18:21: error: 'NEXT' was not declared in this scope
   18 |         if(light.at(NEXT) == 2){
      |                     ^~~~
a.cc:19:17: error: 'flag' was not declared in this scope
   19 |                 flag = 1;
      |                 ^~~~
a.cc:22:9: error: 'NEXT' was not declared in this scope
   22 |         NEXT = light.at(NEXT);
      |         ^~~~
a.cc:25:12: error: 'flag' was not declared in this scope
   25 |         if(flag == 1){
      |            ^~~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i = 0 ; i < N ; i++)
    cin >> vec.at(i);
  
  for(int i = 0 ; i <= N ; i++) {
    if(vec.at(i) == N) cout << -1 << endl;
    if(vec.at(i) == 2) break;
  }
  
  cout << i << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:17:11: error: 'i' was not declared in this scope
   17 |   cout << i << endl;
      |           ^
a.cc:17:21: error: expected '}' at end of input
   17 |   cout << i << endl;
      |                     ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a, b;
  a = 1;
  b = 0;
  cin >> N;
  vector(int) vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  while (true) {
    a = vec.at(a - 1);
    b++;
    if (a == 2) {
      cout << b << endl;
      break;
    }
    else if (b == N) {
      cout << -1 << endl;
      break;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: missing template arguments before '(' token
    8 |   vector(int) vec(N);
      |         ^
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector(int) vec(N);
      |          ^~~
a.cc:10:12: error: 'vec' was not declared in this scope
   10 |     cin >> vec.at(i);
      |            ^~~
a.cc:13:9: error: 'vec' was not declared in this scope
   13 |     a = vec.at(a - 1);
      |         ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,ans,k=1;
  vector<int> vec;
  cin >> N;
  
  for(int i = 0;i < N;++i)
    cin >> vec.at(i);
  for(int j = 0;j < N;++j){
    k = vec.at(k)
    if (k == 1){
      cout << j+1 << endl;
      break;
    }
  if (j == N - 1)
    cout << -1 << endl;
      
  

  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:18: error: expected ';' before 'if'
   11 |     k = vec.at(k)
      |                  ^
      |                  ;
   12 |     if (k == 1){
      |     ~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  //配列にa_iを代入
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  //判定
  int x = 0;
  int counter = 1;
  for(int i = 0; i < N; i++){
    
    //不可能判定
    if(vec.at(x) == 1){
      cout << -1 << endl;
      break;
    }
    
    //成功判定
    else if(vec.at(x) == 2){
      cout << counter << endl;
      break;
    }
    
    //ループ時判定
    else if(cournter >= N){
      cout << -1 << endl;
    }
    
    //継続判定
    else{
      counter += 1;
      x = vec.at(x) - 1;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:13: error: 'cournter' was not declared in this scope; did you mean 'counter'?
   32 |     else if(cournter >= N){
      |             ^~~~~~~~
      |             counter
Language: C++

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

int main()
{
int n;
cin>>n;
vector<int>v;
for (int i = 0; i < n; i++)
{
    int z;
    cin>>z;
    z--;
    v.push_back(z);
}
int now=0,c=0;
for(;;)
{
    if (now==1) 
    {
       cout<<c<<endl;
       break; 
    }
    c++;
    now=v[now];
}
   
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:1: error: 'cin' was not declared in this scope
    7 | cin>>n;
      | ^~~
a.cc:8:1: error: 'vector' was not declared in this scope
    8 | vector<int>v;
      | ^~~~~~
a.cc:8:8: error: expected primary-expression before 'int'
    8 | vector<int>v;
      |        ^~~
a.cc:14:5: error: 'v' was not declared in this scope
   14 |     v.push_back(z);
      |     ^
a.cc:21:8: error: 'cout' was not declared in this scope
   21 |        cout<<c<<endl;
      |        ^~~~
a.cc:21:17: error: 'endl' was not declared in this scope
   21 |        cout<<c<<endl;
      |                 ^~~~
a.cc:25:9: error: 'v' was not declared in this scope
   25 |     now=v[now];
      |         ^
Language: C++

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
	cin >> n;
	vi a(n);
	rep(i,n) cin >> a[i]; a[i]--;
	int now = 0;
	vi seen(n,0);
	seen[0] = 1;
	int cnt = 0;
	while(1){
		now = a[now];
		cnt++;
		if(seen[a[now]] == 1) {
			cout << -1 << endl;
			return;
        }else if(a[now] == 1){
			cout << cnt << endl;
			return;
        }
    }
  
	cout << "error" << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Compiler output:
a.cc: In function 'void Main()':
a.cc:23:33: error: 'i' was not declared in this scope
   23 |         rep(i,n) cin >> a[i]; a[i]--;
      |                                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>a(10000);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
    }
    bool check=false;
    int count = 0;
    int tmp = a.at(0);
    for(int i=0; i<n; i++){
        count++;
        if(tmp==2){
            check = true;
            break;
        }
        tmp=a.at(tmp-1);
    }
    if(check)cout<<count<<endl;
    else cout<<"-1"<<endl;

}

Compiler output:
a.cc:23:1: error: stray '\16' in program
   23 | <U+000E>
      | ^~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,;
  cin >> N;
  
  vector<int> button(N);
  for(int i = 0; i < N; i++){
    cin >> button.at(i);
  }
  
  int num = 1, count = 0;
  for(int i = 0; i <= N; i++){
    num = button.at(num - 1);
    count++;
    
    if(num == 2){
      break;
    }
  }
  
  if(count > N){
    count = -1;
  }
  
  cout << count << endl;
  
  
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: expected unqualified-id before ';' token
    5 |   int N,;
      |         ^
Language: C++

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

int main() {
    int N, cnt = 0, tmp = 0;
    cin >> N;

    vector<int> Button(N);
    for (int i = 0; i < N; i++) {
        int z;
        cin >> z;
        z--;
        Button.at(i) = Z;
    }
    
    //入力層終わり

    for (;; cnt++) {
        
        if (tmp == 1) {
            cout << cnt << endl;
            break;
        }

        if (cnt >= N) {
            cout << "-1" << endl;
        }
        tmp = Button.at(tmp);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:24: error: 'Z' was not declared in this scope
   13 |         Button.at(i) = Z;
      |                        ^
Language: C++

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

int main() {
    int N, cnt = 0;
    cin >> N;

    vector<int> Button(N);
    for (int i = 0; i < N) {
        cin >> Button.at(i);
    }
    
    for (cnt = 0; cnt < N; cnt++) {
       int tmp;
       if (cnt == 0) tmp = 0;
       if (tmp == 1) {
           cnt++;
           break;
       }
        tmp = Button.at(tmp);
    }

    cout << cnt + 1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:26: error: expected ';' before ')' token
    9 |     for (int i = 0; i < N) {
      |                          ^
      |                          ;
Language: C++

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

int main() {
    int N, cnt = 0;
    cin >> N;

    vector<int> Button(N);
    for (int i = 0; i < N) {
        cin >> Button.at(i);
    }
    
    for (int i = 0; i < N; i++) {
        if (i == 1) {
            cnt = -1;
            break;
        }
        cnt++;
    }

    cout << cnt <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:26: error: expected ';' before ')' token
    9 |     for (int i = 0; i < N) {
      |                          ^
      |                          ;
Language: C++

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

int main() {
    int N, cnt = 0;
    cin >> N;

    vector<int> Button(N);
    for (int i == 0; i < N) {
        cin >> Button.at(i);
    }
    
    for (int i = 0; i < N; i++) {
        if (i == 1) {
            cnt = -1;
            break;
        }
        cnt++;
    }
	cout << cnt << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:15: error: expected ';' before '==' token
    9 |     for (int i == 0; i < N) {
      |               ^~~
      |               ;
a.cc:9:16: error: expected primary-expression before '==' token
    9 |     for (int i == 0; i < N) {
      |                ^~
Language: C++

#include<bits/stdc++.h>
int main(){
  int n,k=0,a[n],d=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  while(d<n+1){
    d++;
    k=a[k];
    if(k==1){
      cout << d;
      return 0;
    }
  }
  cout << -1;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 |   cin >> n;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   12 |       cout << d;
      |       ^~~~
      |       std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:16:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |   cout << -1;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

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

int main() {
    int n;
    cin >> n;
    vector<int> a;
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }
    vector<bool> did(n,false);
    int now = 0;
    int cnt = 0;
    for {
        if(now == 1) {
            cout << cnt << endl;
            return 0;
        }
        if(did[now]) {
            cout << -1 << endl;
            return 0;
        }
        did[now] = true;
        cnt++;
        now = a[now];
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: expected '(' before '{' token
   20 |     for {
      |         ^
      |         (
a.cc:20:9: error: expected primary-expression before '{' token
a.cc:33:1: error: expected primary-expression before '}' token
   33 | }
      | ^
a.cc:32:6: error: expected ';' before '}' token
   32 |     }
      |      ^
      |      ;
   33 | }
      | ~     
a.cc:33:1: error: expected primary-expression before '}' token
   33 | }
      | ^
a.cc:32:6: error: expected ')' before '}' token
   32 |     }
      |      ^
      |      )
   33 | }
      | ~     
a.cc:20:9: note: to match this '('
   20 |     for {
      |         ^
a.cc:33:1: error: expected primary-expression before '}' token
   33 | }
      | ^
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0;i<N;i++)
    cin >> vec.at(i);
  
  int p = vec.at(0);
  int t=0;
  int j;
  
  for(j=0;j<N;j++){
    t++;
    if(p==2)
      break;
    else
      p=vec.at(p-1)
  }

  if (j==N)
    cout << -1 << endl;
  else
    cout << t << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:20: error: expected ';' before '}' token
   21 |       p=vec.at(p-1)
      |                    ^
      |                    ;
   22 |   }
      |   ~
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0;i < N;i++) {
    cin >> vec.at(i);
  }
  
  int A = vec.at(0);
  int B = 0;
  int j;
  
  for (j = 0;j < N;j++) {
    B++;
    for (A == 2) {
      break;
    }
    A = vec.at(A - 1);
  }
  
  if (j == N) {
    cout << -1 << endl;
  } else {
    cout << B << endl;
  }
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:16: error: expected ';' before ')' token
   19 |     for (A == 2) {
      |                ^
      |                ;
a.cc:23:3: error: expected primary-expression before '}' token
   23 |   }
      |   ^
a.cc:22:23: error: expected ')' before '}' token
   22 |     A = vec.at(A - 1);
      |                       ^
      |                       )
   23 |   }
      |   ~                    
a.cc:19:9: note: to match this '('
   19 |     for (A == 2) {
      |         ^
a.cc:23:3: error: expected primary-expression before '}' token
   23 |   }
      |   ^
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N;i++) {
    cin >> vet.at(i);
  }
  
  int A = vec.at(0);
  int B = 0;
  int j;
  
  for (j = 0;j < N - 1;j++) {
    B++;
    if (A == 2) {
      break;
    }
    A = vec.at(A - 1);
  }
  
  if (j == N - 1) {
    cout << -1 << endl;
  } else {
    cout << B << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: 'vet' was not declared in this scope; did you mean 'vec'?
   10 |     cin >> vet.at(i);
      |            ^~~
      |            vec
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i = 0; i < N;i++) {
    cin >> vet.at(i);
  }
  
  int A = vec.at(0);
  int B = 0;
  int j;
  
  for (j = 0;j < N - 1;j++) {
    B++;
    if (A == 2) {
      break;
    }
    A = vec.at(A - 1);
  }
  
  if (j == N - 1) {
    cout << -1 << endl;
  } else {
    cout << B << endl;
  }
}

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

#i n cl u d e <s t d i o . h>
#i n cl u d e <v e c t o r>
#i n cl u d e <al g o ri thm>
u si n g namespace s t d ;
i n t main ( )
{
i n t n ;
s c a n f (”%d ” , &n ) ;
v e c t o r<i n t>v ;
f o r ( i n t i = 0 ; i < n ; i++)
{
i n t z ;
s c a n f (”%d ” , &z ) ;
z−−;
v . push back ( z ) ;
}
i n t now = 0 , c = 0 ;
f o r ( ; ; )
{
i f ( now == 1 )
{
p r i n t f (”%d\n ” , c ) ;
break ;
}
i f ( c >= n )
{
p r i n t f (”−1\n ” ) ;
break ;
}
c++;
now = v [ now ] ;
}
}


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #i; did you mean #if?
    1 | #i n cl u d e <s t d i o . h>
      |  ^
      |  if
a.cc:2:2: error: invalid preprocessing directive #i; did you mean #if?
    2 | #i n cl u d e <v e c t o r>
      |  ^
      |  if
a.cc:3:2: error: invalid preprocessing directive #i; did you mean #if?
    3 | #i n cl u d e <al g o ri thm>
      |  ^
      |  if
a.cc:8:12: error: extended character ” is not valid in an identifier
    8 | s c a n f (”%d ” , &n ) ;
      |            ^
a.cc:8:16: error: extended character ” is not valid in an identifier
    8 | s c a n f (”%d ” , &n ) ;
      |                ^
a.cc:13:12: error: extended character ” is not valid in an identifier
   13 | s c a n f (”%d ” , &z ) ;
      |            ^
a.cc:13:16: error: extended character ” is not valid in an identifier
   13 | s c a n f (”%d ” , &z ) ;
      |                ^
a.cc:14:1: error: extended character − is not valid in an identifier
   14 | z−−;
      | ^
a.cc:14:1: error: extended character − is not valid in an identifier
a.cc:22:14: error: extended character ” is not valid in an identifier
   22 | p r i n t f (”%d\n ” , c ) ;
      |              ^
a.cc:22:17: error: stray '\' in program
   22 | p r i n t f (”%d\n ” , c ) ;
      |                 ^
a.cc:22:20: error: extended character ” is not valid in an identifier
   22 | p r i n t f (”%d\n ” , c ) ;
      |                    ^
a.cc:27:14: error: extended character ” is not valid in an identifier
   27 | p r i n t f (”−1\n ” ) ;
      |              ^
a.cc:27:14: error: extended character − is not valid in an identifier
a.cc:27:17: error: stray '\' in program
   27 | p r i n t f (”−1\n ” ) ;
      |                 ^
a.cc:27:20: error: extended character ” is not valid in an identifier
   27 | p r i n t f (”−1\n ” ) ;
      |                    ^
a.cc:4:1: error: 'u' does not name a type
    4 | u si n g namespace s t d ;
      | ^
a.cc:5:1: error: 'i' does not name a type
    5 | i n t main ( )
      | ^
Language: C++

int main(){
    long n,f(0),ans(0),a(0);
    cin >> n;

    long h[n];

    for(int i=0;i<n;i++){
        cin >> h[i];
        if(h[i]==2)
            f++;
    }

    a = h[0];

    if(f==0)
        cout << -1 << endl;

    for(int i=0;i<n;i++){
        a = h[a-1];
        ans++;
        if(a==2){
            cout << ans+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> n;
      |     ^~~
a.cc:16:9: error: 'cout' was not declared in this scope
   16 |         cout << -1 << endl;
      |         ^~~~
a.cc:16:23: error: 'endl' was not declared in this scope
   16 |         cout << -1 << endl;
      |                       ^~~~
a.cc:22:13: error: 'cout' was not declared in this scope
   22 |             cout << ans+1 << endl;
      |             ^~~~
a.cc:22:30: error: 'endl' was not declared in this scope
   22 |             cout << ans+1 << endl;
      |                              ^~~~
a.cc:26:5: error: 'cout' was not declared in this scope
   26 |     cout << -1 << endl;
      |     ^~~~
a.cc:26:19: error: 'endl' was not declared in this scope
   26 |     cout << -1 << endl;
      |                   ^~~~
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0, ans = a[0];
  
  rep(i,n){
    if(a[num] == 2){
      ++ans;
      cout << ans << endl;
      return 0;
    }
    if(a[num] == 1){
      cout << -1 << endl;
      return 0;
    }
    num = a[num];
    ++ans;
  }
  cout << -1 << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: redeclaration of 'int ans'
   12 |   int ans = 0, ans = a[0];
      |                ^~~
a.cc:12:7: note: 'int ans' previously declared here
   12 |   int ans = 0, ans = a[0];
      |       ^~~
a.cc:15:10: error: 'num' was not declared in this scope; did you mean 'enum'?
   15 |     if(a[num] == 2){
      |          ^~~
      |          enum
a.cc:20:10: error: 'num' was not declared in this scope; did you mean 'enum'?
   20 |     if(a[num] == 1){
      |          ^~~
      |          enum
a.cc:24:5: error: 'num' was not declared in this scope; did you mean 'enum'?
   24 |     num = a[num];
      |     ^~~
      |     enum
Language: C++

//B - Trained? 2017/06/24
#include <bits/stdc++.h>
using namespace std;

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

    int ans=1;int cnt=0;
    for(int i=1;i<=n;){
        if(a[i]==2) break;
        i=a[i];
        ++cnt;
        if(cnt==n+1) {cout << -1 << endl; return 0};
        ++ans;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:51: error: expected ';' before '}' token
   15 |         if(cnt==n+1) {cout << -1 << endl; return 0};
      |                                                   ^
      |                                                   ;
Language: C++

//B - Trained? 2017/06/24
#include <bits/stdc++.h>
using namespace std;

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

    int ans=1;cnt=0;
    for(int i=1;i<=n;){
        if(a[i]==2) break;
        i=a[i];
        ++cnt;
        if(cnt==n+1) {cout << -1 << endl; return 0};
        ++ans;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: 'cnt' was not declared in this scope; did you mean 'int'?
   10 |     int ans=1;cnt=0;
      |               ^~~
      |               int
a.cc:15:51: error: expected ';' before '}' token
   15 |         if(cnt==n+1) {cout << -1 << endl; return 0};
      |                                                   ^
      |                                                   ;
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int N;
  vector<int> a(N);
  cin >> N;
  rep(i, N) cin >> a.at(i);
  int cnt = 0;
  int tmp_a = 0;
  rep(i, N) {
    tmp_a = a.at(tmp_a) - 1;
    ++cnt;
    if (tmp_a == 1) break;
  }
  if (x == 1) cout << cnt << endl;
  else cout << -1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:7: error: 'x' was not declared in this scope
   18 |   if (x == 1) cout << cnt << endl;
      |       ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int N;
  vector<int> a(N);
  cin >> N;
  rep(i, N) cin >> a.at(i);
  bool flag = false;
  int tmp_a = 0;
  rep(i, N) {
    tmp_a = a.at(tmp_a) - 1;
    if (tmp_a == 1) {
      flag = true;
      break;
    }
    if (tmp_a == 0) break;
  }
  if (flag) cout << cnt << endl;
  else cout << -1 << endl;
}


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

#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int N;
  vector<int> a(N);
  cin >> N;
  rep(i, N) cin >> a.at(i);
  bool flag = false;
  int tmp_a = 0;
  int cnt = 0;
  rep(i, N) {
    tmp_a = a.at(tmp_a) - 1;
    ++cnt;
    if (tmp_a == 1) {
      flag = true;
      break;
    }
    else if (tmp_a == 0) break;
  }
  if (flag) cout << cnt << endl;
  else cout << -1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> a(N);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> a(N);
      |          ^~~
a.cc:9:20: error: 'a' was not declared in this scope
    9 |   rep(i, N) cin >> a.at(i);
      |                    ^
a.cc:14:13: error: 'a' was not declared in this scope
   14 |     tmp_a = a.at(tmp_a) - 1;
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  
  vector<int> bot(N);
  
  for(int i=0;i<N;i++)
    cin>>bot.at(i);
  
  int a=1,count=0;
  
  for(int i=0;i<N;i++){
    a=bot.at(a);
    count++;
    if(a==2)
      break!;
  }
  
  if(count==0)
    count=-1;
  
  cout<<count<<endi;
}
    
    


Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: expected ';' before '!' token
   19 |       break!;
      |            ^
      |            ;
a.cc:19:13: error: expected primary-expression before ';' token
   19 |       break!;
      |             ^
a.cc:25:16: error: 'endi' was not declared in this scope
   25 |   cout<<count<<endi;
      |                ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  
  vctor<int> bot(N);
  
  for(int i=0;i<N;i++)
    cin>>bot.at(i);
  
  int a=1,count=0;
  
  for(int i=0;i<N;i++){
    a=bot.at(a);
    count++;
    if(a==2)
      break!;
  }
  
  if(count==0)
    count=-1;
  
  cout<<count<<endi;
}
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vctor' was not declared in this scope
    8 |   vctor<int> bot(N);
      |   ^~~~~
a.cc:8:9: error: expected primary-expression before 'int'
    8 |   vctor<int> bot(N);
      |         ^~~
a.cc:11:10: error: 'bot' was not declared in this scope
   11 |     cin>>bot.at(i);
      |          ^~~
a.cc:16:7: error: 'bot' was not declared in this scope
   16 |     a=bot.at(a);
      |       ^~~
a.cc:19:12: error: expected ';' before '!' token
   19 |       break!;
      |            ^
      |            ;
a.cc:19:13: error: expected primary-expression before ';' token
   19 |       break!;
      |             ^
a.cc:25:16: error: 'endi' was not declared in this scope
   25 |   cout<<count<<endi;
      |                ^~~~
Language: C++

#include<iostream>using namespace std;main(void){
int n,c=0; cin>>n; int a[n]; for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){if(a[i]==2) {cout<<c;return 0;} else if(a[i]==-1){cout<<-1;return 0;}else{
 i=a[i]-1; a[i]=-1; c++;
}
}
}

Compiler output:
a.cc:1:25: warning: extra tokens at end of #include directive
    1 | #include<iostream>using namespace std;main(void){
      |                         ^~~~~~~~~
a.cc:1:9: fatal error: iostream>usin: No such file or directory
    1 | #include<iostream>using namespace std;main(void){
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
    a[i]--;
  }
  bool<int> C(N,false);
  int p = 0;
  int count = 0;
  while (!C[p]){
    C[p] = true;
    p = a[p];
    count++;
  }
  if (C[2]) cout << count;
  if (!C[2]) cout << -1;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'bool' is not a template
   11 |   bool<int> C(N,false);
      |   ^~~~
a.cc:11:22: error: expression list treated as compound expression in initializer [-fpermissive]
   11 |   bool<int> C(N,false);
      |                      ^
a.cc:14:12: error: invalid types 'bool[int]' for array subscript
   14 |   while (!C[p]){
      |            ^
a.cc:15:6: error: invalid types 'bool[int]' for array subscript
   15 |     C[p] = true;
      |      ^
a.cc:19:8: error: invalid types 'bool[int]' for array subscript
   19 |   if (C[2]) cout << count;
      |        ^
a.cc:20:9: error: invalid types 'bool[int]' for array subscript
   20 |   if (!C[2]) cout << -1;
      |         ^
Language: Java

import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] a = new int[n];
      int i;
      for(i=0;i<n;i++){
        a[i] = sc.nextInt();
      }
      int ans = 0;
      int total = 0;
      for(i=0;i<n+i++){
        if(a[i]==2){
          total++;
          ans = 1;
          break;
        }else{
          total++;
        }
      }
      if(ans==1){
        System.out.println(-1);
      }else{
        System.out.println(total);
      }
        
  }
}


Compiler output:
Main.java:14: error: ';' expected
      for(i=0;i<n+i++){
                     ^
1 error
Language: C++

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

int main(){
  int N; cin >> N;
  vector<int> bottom(N);
  for(int i=0;i<N;i++){
    cin >> bottom.at(i);
  }
  int num= bottom.at(0);
  int count = 0;
  while(true){
    num = bottom.at(num);
    count++;
    if(num == 2){
      cout << count << endl;
      return 0;
    }
    if(count > MAX){
      cout << -1 << endl;
      return 0;
    }
  }
}
    
      

Compiler output:
a.cc: In function 'int main()':
a.cc:21:19: error: expected primary-expression before ')' token
   21 |     if(count > MAX){
      |                   ^
Language: C++

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

int main() {
  int n=0;
  cin >> n;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec.at(i);
  
  int now=0;
  
  vector<bool> visited(n, false);
  visited.at(0) = true;
  
  int ans=0;
  
  while (now == 1) {
    if !(visited.at(vec.at(now)-1)) {
      visited.at(vec.at(now)-1) = true;
      now = vec.at(now)-1;
      ans++;
    }
    else {
      ans = -1;
      break;
    }
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:8: error: expected '(' before '!' token
   19 |     if !(visited.at(vec.at(now)-1)) {
      |        ^
      |        (
a.cc:24:5: error: 'else' without a previous 'if'
   24 |     else {
      |     ^~~~
Language: C++

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

int main() 
{
	int N,ai;
  	
  	cin >> N;
  	Vector<int> a(N,0);
  	for(int i = 0; i < N; i++)
    {
    	cin >> a[i];
    }
  	ai = a[0];
  	for(int i = 0; i < N; i++)
    {
    	ai = a[ai];
      if(ai == 2)
      {
      	cout << 1 << endl;
        exit(0);
      } 
    }
  	cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'Vector' was not declared in this scope
    9 |         Vector<int> a(N,0);
      |         ^~~~~~
a.cc:9:16: error: expected primary-expression before 'int'
    9 |         Vector<int> a(N,0);
      |                ^~~
a.cc:12:16: error: 'a' was not declared in this scope
   12 |         cin >> a[i];
      |                ^
a.cc:14:14: error: 'a' was not declared in this scope; did you mean 'ai'?
   14 |         ai = a[0];
      |              ^
      |              ai
Language: C++

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

int main(){
	int N , a , count=1,tmp = 1;
  	vector<int> A(N);
  	for (int i = 0 ; i < N ; i++){
      	cin >> A[i];
    }
  	while (A.[tmp] != 2){
      count++;
      A[tmp]=A[A[tmp]];
      if (count > N)
        cout << -1 << endl;
      break;
    }
  cout << count <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: expected unqualified-id before '[' token
   10 |         while (A.[tmp] != 2){
      |                  ^
Language: C++

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

int main(){
	int N , a , count=1,tmp = 1;
  	vector<int> A(N);
  	for (int i = 0 ; i < N ; i++){
      	cin >> a;
    	A.at(i) = a;
    }
  	for (int i = 0 ; i < N ; i++){
      	A.at(tmp-1) = tmp-1
    	if(A.at(tmp-1) == 2){
          	cout << count << endl;
        	break;
        }
      	count++;
      	if(count == N)
        	cout << "-1" << endl;
    }
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:28: error: expected ';' before 'if'
   12 |         A.at(tmp-1) = tmp-1
      |                            ^
      |                            ;
   13 |         if(A.at(tmp-1) == 2){
      |         ~~
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
    A[i] --;
  }
  int push=0,cur=0;
  while(true){
    push ++;
    int next=A[cur];
    if(next==-1){
      cout << -1 << endl;
      return 0;
    }else if(next==1){
      cout << push << endl;
      return 0;
    }
    A[cur]=-1;
    cur = next;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:25:4: error: expected '}' at end of input
   25 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main() {
  int N;
  cin >> N ;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);}
  
  int light = 1;
  int count = 0;
  
  for(int i=0; i < N; i++){
    if(light == 2){cout << count << endl; break;}
    if(count > N){cout <<-1<< endl; break;}
  count++;light = a.at(light)}

}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:30: error: expected ';' before '}' token
   17 |   count++;light = a.at(light)}
      |                              ^
      |                              ;
Language: C++

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

int main() {
  int N;
  cin >> N ;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i)}
  
  int light = 1;
  int count = 0;
  
  for(int i=0; i < N; i++){
    if(light != 2){ count++; light =a.at(light);}
    else {count++; break;}}
  if(count++ == N){cout << -1 << endl;}
  else { cout << count << endl;}

}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: expected ';' before '}' token
    9 |     cin >> a.at(i)}
      |                   ^
      |                   ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
int count=0;
int c=1;
int a;
int main(){
  cin>>a;
  vector<int> b(a);
  for(int i=0;i<a;i++)cin>>b.at(i);
/*  for(int i=1;i<a;i++){
    if(c==2){
      break;
    }
      count++;
    c=b.at(c-1);
  }*/
  if(count==0)cout<<-1<<endl;
  else cout<<count<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:6: error: reference to 'count' is ambiguous
   17 |   if(count==0)cout<<-1<<endl;
      |      ^~~~~
In file included from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:3:5: note:                 'int count'
    3 | int count=0;
      |     ^~~~~
a.cc:18:14: error: reference to 'count' is ambiguous
   18 |   else cout<<count<<endl;
      |              ^~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
/usr/include/c++/14/bits/stl_algo.h:4025:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4025 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
a.cc:3:5: note:                 'int count'
    3 | int count=0;
      |     ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int> vec;
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int j=0,c=0;
  while(j==1){
    int k=v.at(j)-1;
    j=k;
    c++;
    if(c>=N){
      cout<<-1<<endl;
      break;
    }
  }
  cout<<c<<endl;
}
      
    

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'v' was not declared in this scope
   13 |     int k=v.at(j)-1;
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int> vec;
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int j=0,c=0;
  while(j==1){
    j=v.at(j)-1;
    c++;
    if(c>=N){
      cout<<-1<<endl;
      break;
    }
  }
  cout<<c<<endl;
}
      
    

Compiler output:
a.cc: In function 'int main()':
a.cc:13:7: error: 'v' was not declared in this scope
   13 |     j=v.at(j)-1;
      |       ^
Language: C++

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

int main(){
int n,a,count=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    count++;
    if(a==2){
      cout<<count;
      return 0;
    }
  }
    cout<<-1;
  }
}

Compiler output:
a.cc:18:1: error: expected declaration before '}' token
   18 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  int a = vec.at(0);
  for(int i = 0; i < N; i++){
    if(a == 2){
      cout << i + 1 << endl;
      break;
    }
    else if(i == N -1){
      cout << -1 << endl;
      break;
    }
    int b = vec.at(a) - 1
    a = vec.at(b);
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: expected ',' or ';' before 'a'
   22 |     a = vec.at(b);
      |     ^