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

#include <iostream>
#include <vector>

using namespace std;

//https://atcoder.jp/contests/abc065/tasks/abc065_b

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

    vector<int> a(N);

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

    int light = 1; //最初は1のライトが光ってる
    int count = 0;

    for(int i=0;i<N;i++){
        if(light == 2) break;　//2が光ったら終了
        light = a.at(light-1) ;
        count++;
    }

    if(light !=2) count = -1;
    cout << count << endl; 

    return 0;
}

Compiler output:
a.cc:22:30: error: extended character 　 is not valid in an identifier
   22 |         if(light == 2) break;　//2が光ったら終了
      |                              ^
a.cc: In function 'int main()':
a.cc:22:30: error: '\U00003000' was not declared in this scope
   22 |         if(light == 2) break;　//2が光ったら終了
      |                              ^~
Language: C++

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

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

#include <iostream>
using namespace std;

int main(){
  
  int N; cin >> N;
  int count_lst[N]={0}; count_lst[0] = 1;
  
  int a_lst[N];
  for(int i=0; i<N; i++) cin >> a[i];
  
  int num=1;
  int count=0;
  for(int i=0; i<N; i++){
    num = a_lst[num-1];
    count++;
    if(count_lst[num-1] == 1){
      count = -1;
      break;
    }else if(num=2) break;
    count_lst[num-1] = 1;
  }
  cout << count << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:33: error: 'a' was not declared in this scope
   10 |   for(int i=0; i<N; i++) cin >> a[i];
      |                                 ^
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 now = 0, c = 0;
  for (;;) {
    if (now == 2) {
      cout << c << endl;
      break;
    }
    if (c >= N) {
      cout << -1 << endl;
      break;
    }
    c++;
    now = a.at(now - 1);
}

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

#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	vector<int>v;
	for(int i=0;i<n;i++){
		int tmp;
		scanf("%d",&tmp);
		tmp−−;
		v.push_back(tmp);
	}
	int now = 0,c=0;
	for ( ; ; ){
		if(now == 1){
		printf("%d\n",c);
			break;
		}
		if( c >= n ){
			printf("−1\n");
				break;
		}
		c++;
		now = v[now];
	}
}

Compiler output:
a.cc:13:17: error: extended character − is not valid in an identifier
   13 |                 tmp−−;
      |                 ^
a.cc:13:17: error: extended character − is not valid in an identifier
a.cc: In function 'int main()':
a.cc:13:17: error: 'tmp\U00002212\U00002212' was not declared in this scope
   13 |                 tmp−−;
      |                 ^~~~~
Language: C++

#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	vector<int>v;
	for(int i=0;i<n;i++){
		int tmp;
		scanf("%d",&tmp);
		tmp−−;
		v.push_back(tmp);
	}
	int now = 0,c=0;
	for ( ; ; ){
		if(now == 1){
		printf(”%d\n”,c);
			break;
		}
		if( c >= n ){
			printf(”−1\n”);
				break;
		}
		c++;
		now = v[now];
	}
}

Compiler output:
a.cc:13:17: error: extended character − is not valid in an identifier
   13 |                 tmp−−;
      |                 ^
a.cc:13:17: error: extended character − is not valid in an identifier
a.cc:19:24: error: extended character ” is not valid in an identifier
   19 |                 printf(”%d\n”,c);
      |                        ^
a.cc:19:27: error: stray '\' in program
   19 |                 printf(”%d\n”,c);
      |                           ^
a.cc:19:28: error: extended character ” is not valid in an identifier
   19 |                 printf(”%d\n”,c);
      |                            ^
a.cc:23:32: error: extended character ” is not valid in an identifier
   23 |                         printf(”−1\n”);
      |                                ^
a.cc:23:32: error: extended character − is not valid in an identifier
a.cc:23:35: error: stray '\' in program
   23 |                         printf(”−1\n”);
      |                                   ^
a.cc:23:36: error: extended character ” is not valid in an identifier
   23 |                         printf(”−1\n”);
      |                                    ^
a.cc: In function 'int main()':
a.cc:13:17: error: 'tmp\U00002212\U00002212' was not declared in this scope
   13 |                 tmp−−;
      |                 ^~~~~
a.cc:19:24: error: '\U0000201d' was not declared in this scope
   19 |                 printf(”%d\n”,c);
      |                        ^
a.cc:19:26: error: 'd' was not declared in this scope
   19 |                 printf(”%d\n”,c);
      |                          ^
a.cc:23:32: error: '\U0000201d\U000022121' was not declared in this scope
   23 |                         printf(”−1\n”);
      |                                ^~~
Language: C++

#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	scanf(”%d”,&n);
	vector<int>v;
	for(int i=0;i<n;i++){
		int tmp;
		scanf(”%d”,&tmp);
		tmp−−;
		v.push_back(tmp);
	}
	int now = 0,c=0;
	for ( ; ; ){
		if(now == 1){
		printf(”%d\n”,c);
			break;
		}
		if( c >= n ){
			printf(”−1\n”);
				break;
		}
		c++;
		now = v[now];
	}
}


Compiler output:
a.cc:8:15: error: extended character ” is not valid in an identifier
    8 |         scanf(”%d”,&n);
      |               ^
a.cc:8:17: error: extended character ” is not valid in an identifier
    8 |         scanf(”%d”,&n);
      |                 ^
a.cc:12:23: error: extended character ” is not valid in an identifier
   12 |                 scanf(”%d”,&tmp);
      |                       ^
a.cc:12:25: error: extended character ” is not valid in an identifier
   12 |                 scanf(”%d”,&tmp);
      |                         ^
a.cc:13:17: error: extended character − is not valid in an identifier
   13 |                 tmp−−;
      |                 ^
a.cc:13:17: error: extended character − is not valid in an identifier
a.cc:19:24: error: extended character ” is not valid in an identifier
   19 |                 printf(”%d\n”,c);
      |                        ^
a.cc:19:27: error: stray '\' in program
   19 |                 printf(”%d\n”,c);
      |                           ^
a.cc:19:28: error: extended character ” is not valid in an identifier
   19 |                 printf(”%d\n”,c);
      |                            ^
a.cc:23:32: error: extended character ” is not valid in an identifier
   23 |                         printf(”−1\n”);
      |                                ^
a.cc:23:32: error: extended character − is not valid in an identifier
a.cc:23:35: error: stray '\' in program
   23 |                         printf(”−1\n”);
      |                                   ^
a.cc:23:36: error: extended character ” is not valid in an identifier
   23 |                         printf(”−1\n”);
      |                                    ^
a.cc: In function 'int main()':
a.cc:8:15: error: '\U0000201d' was not declared in this scope
    8 |         scanf(”%d”,&n);
      |               ^
a.cc:8:17: error: 'd\U0000201d' was not declared in this scope
    8 |         scanf(”%d”,&n);
      |                 ^~
a.cc:13:17: error: 'tmp\U00002212\U00002212' was not declared in this scope
   13 |                 tmp−−;
      |                 ^~~~~
a.cc:19:26: error: 'd' was not declared in this scope
   19 |                 printf(”%d\n”,c);
      |                          ^
a.cc:23:32: error: '\U0000201d\U000022121' was not declared in this scope
   23 |                         printf(”−1\n”);
      |                                ^~~
Language: C++

#include<iostream>
#include<vector>

int main(){
  
  int a; cin >> a;
  int cur = 1;
  vector<int> v(a+1);
  for(int i = 1; i <= a; ++i) cin >> v[i];
  
  for(int i = 0; i < 100009; ++i){
    cur = v[cur];
    if(cur == 2){
      cout << i+1;
      return 0;
    }
  }
  
  
  cout << -1;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   int a; cin >> a;
      |          ^~~
      |          std::cin
In file included 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:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> v(a+1);
      |   ^~~~~~
a.cc:8:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> v(a+1);
      |          ^~~
a.cc:9:38: error: 'v' was not declared in this scope
    9 |   for(int i = 1; i <= a; ++i) cin >> v[i];
      |                                      ^
a.cc:12:11: error: 'v' was not declared in this scope
   12 |     cur = v[cur];
      |           ^
a.cc:14:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   14 |       cout << i+1;
      |       ^~~~
      |       std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:20:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |   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<iostream>

int main(){
  
  int a; cin >> a;
  int cur = 1;
  vector<int> v(a+1);
  for(int i = 1; i <= a; ++i) cin >> v[i];
  
  for(int i = 0; i < 100009; ++i){
    cur = v[cur];
    if(cur == 2){
      cout << i+1;
      return 0;
    }
  }
  
  
  cout << -1;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    5 |   int a; cin >> a;
      |          ^~~
      |          std::cin
In file included 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:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> v(a+1);
      |   ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> v(a+1);
      |          ^~~
a.cc:8:38: error: 'v' was not declared in this scope
    8 |   for(int i = 1; i <= a; ++i) cin >> v[i];
      |                                      ^
a.cc:11:11: error: 'v' was not declared in this scope
   11 |     cur = v[cur];
      |           ^
a.cc:13:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   13 |       cout << i+1;
      |       ^~~~
      |       std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:19:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   19 |   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<iostream.h>

int main(){
  
  int a; cin >> a;
  int cur = 1;
  vector<int> v(a+1);
  for(int i = 1; i <= a; ++i) cin >> v[i];
  
  for(int i = 0; i < 100009; ++i){
    cur = v[cur];
    if(cur == 2){
      cout << i+1;
      return 0;
    }
  }
  
  
  cout << -1;
  return 0;
}


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

#include<stdio.h>

int main(){
  
  int a; cin >> a;
  int cur = 1;
  vector<int> v(a+1);
  for(int i = 1; i <= a; ++i) cin >> v[i];
  
  for(int i = 0; i < 100009; ++i){
    cur = v[cur];
    if(cur == 2){
      cout << i+1;
      return 0;
    }
  }
  
  
  cout << -1;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope
    5 |   int a; cin >> a;
      |          ^~~
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<int> v(a+1);
      |   ^~~~~~
a.cc:7:10: error: expected primary-expression before 'int'
    7 |   vector<int> v(a+1);
      |          ^~~
a.cc:8:38: error: 'v' was not declared in this scope
    8 |   for(int i = 1; i <= a; ++i) cin >> v[i];
      |                                      ^
a.cc:11:11: error: 'v' was not declared in this scope
   11 |     cur = v[cur];
      |           ^
a.cc:13:7: error: 'cout' was not declared in this scope
   13 |       cout << i+1;
      |       ^~~~
a.cc:19:3: error: 'cout' was not declared in this scope
   19 |   cout << -1;
      |   ^~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    int N;
    cin >> N;

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

    int b[N];
    b[0] = a[0];

    int ans = 0;

    for(int i = 0; i < N; i++) {

        if(b[i] == 1) {
            ans = -1;
            break;
        }
        else if(b[i] == 2) {
            ans = i+1;
            break;
        }
        else {
            b[i+1] = a[a[i]];
        }
    }

    if(i == N) {
        ans = -1;
    }

    cout << ans;

    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:8: error: 'i' was not declared in this scope
   35 |     if(i == N) {
      |        ^
Language: C++

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin>>N;
  int A[N];
  rep(i,N)
    cin>>A[i];
  bool B[N];
  rep(i,N)
    B[i]=false;
  B[0]=true;
  int nex=0;
  int cnt=0;
  rep(i,N){
    tmp=nex;
    nex=A[tmp];
    cnt++;
    if(B[nex]){
      cout<<-1<<endl;
      return 0;
    }
    if(nex==2){
      cout<<cnt<<endl;
      return 0;
    }
  }

}
  





Compiler output:
a.cc: In function 'int main()':
a.cc:35:5: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   35 |     tmp=nex;
      |     ^~~
      |     tm
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  vector<int> btn(n);
  int k=1;
  for(int i=0;i<n;i++){
    cin>>btn[i];
  }  
  for(int j=0;j<n+1;j++){
    if(btn[k-1]==2)cout<<j+1<<endl; break;
    else k=btn[k-1];
    if(j==n)cout<<-1<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'else' without a previous 'if'
   12 |     else k=btn[k-1];
      |     ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int count = 1;
	array<int,10000> a = {};
	for (int i = 0; i < n; i++) cin >> ai;
	
	array<bool, 10000> check = {};
	for (int i = 0; a[i] != 2; i = a[i]-1)
	{
		if (check[i])
		{
			count = -1;
			break;
		}
		count++;
		check[i] = true;
	}

	cout << count << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:44: error: 'ai' was not declared in this scope; did you mean 'i'?
   11 |         for (int i = 0; i < n; i++) cin >> ai;
      |                                            ^~
      |                                            i
Language: C++

#include<iostream>
#include<vector>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: expected ';' before '-' token
    9 |   for(int i - 0;i < N;i++) {
      |            ^~
      |            ;
a.cc:9:22: error: expected ')' before ';' token
    9 |   for(int i - 0;i < N;i++) {
      |      ~               ^
      |                      )
a.cc:9:23: error: 'i' was not declared in this scope
    9 |   for(int i - 0;i < N;i++) {
      |                       ^
a.cc:13:7: error: redeclaration of 'int N'
   13 |   int N = 0;
      |       ^
a.cc:6:7: note: 'int N' previously declared here
    6 |   int N;
      |       ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>btn(N,0);
  
  for(int i=0;i<N;i++){
    cin >> btn[i];
  }
  
  int now_btn = 0;
  int ans = 0;
  
  while(1){
    now_btn = btn[now_btn] - 1;
    ans++;
    if(now_btn == 1)
      break;
    else if(now_btn == 0){
      ans = -1;
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:30:12: error: expected '}' at end of input
   30 |   return 0;
      |            ^
a.cc:4:15: note: to match this '{'
    4 | int main(void){
      |               ^
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for(int i=1; i<=N; i++) {
    cin >> x[i];
  }
  int b=1, ans=0, v;
  while(x[b] != 2){
    if(x[b] = 1) {
      ans=-1;
      break;
    }
    else{
      v=b;
      ans++;
      b=x[b];
      x[v]=1;
    }
  }
  cout << s;
  return 0;
}
      

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

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

int main() {
  int N;
  cin >> N;
  vector<int> x(N);
  for(int i=1; i<=N; i++) {
    cin >> x[i];
  }
  int b=1, ans=0, v;
  while(x[b] != 2){
    if(x[b] = 1) {
      ans=-1;
      break;
    }
    else{
      v=b;
      ans++;
      b=x[b];
      x[v]=1
    }
  }
  cout << s;
  return 0;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: expected ';' before '}' token
   21 |       x[v]=1
      |             ^
      |             ;
   22 |     }
      |     ~        
a.cc:24:11: error: 's' was not declared in this scope
   24 |   cout << s;
      |           ^
Language: C++

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int N = sc.nextInt();
		int[] a = new int[N+1];
		int ans = 0;
		
		for (int i= 1; i <= N; i++){
			a[i] = sc.nextInt();
		}
		int x = 1;
		while (ans < N){
			x = a[x];
			ans++;
			if (x == 2) {
				System.out.println(ans);
				sc.close();
				return;
			}
		}
		
		System.out.println("-1");
		sc.close();
	}
}


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

#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i=0; i < N; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  bool flag = false;
  int now = 1;
  for (int i+0; i < N; ++i) {
    now = a[now -1];
    ++ans;
    if (now == 2) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << ans << "\n";
  }
  else {
    cout << "-1\n";
  }
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: expected ';' before '+' token
   14 |   for (int i+0; i < N; ++i) {
      |             ^
      |             ;
a.cc:14:22: error: expected ')' before ';' token
   14 |   for (int i+0; i < N; ++i) {
      |       ~              ^
      |                      )
a.cc:14:26: error: 'i' was not declared in this scope
   14 |   for (int i+0; i < N; ++i) {
      |                          ^
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> botton(N);

  int i;
  for(i=0;i<N;i++){
    cin >> botton(i);
  }
  
  int hop;
  int light;
  hop = 0;
  light = 0;
  for(i=0;i<N;i++){
    if(botton.at(light) == 0){
      hop = -1;
      break;
    }
    if(botton.at(light) == 1){
      hop += 1;
      break;
    }
    light = botton.at(light);
    botton.at(light) = 0;
    hop += 1;  
  }
  cout << hop << endl;
}


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

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

int main() {
  int N;   
  vector<int> botton(N);

  int i;
  for(i=0;i<N;i++){
    cin >> botton(i);
  }
  
  int hop;
  int light;
  hop = 0;
  light = 0;
  for(i=0;i<N;i++){
    if(botton.at(light) == 0){
      hop = -1;
      break;
    }
    if(botton.at(light) == 1){
      hop += 1;
      break;
    }
    light = botton.at(light);
    botton.at(light) = 0;
    hop += 1;  
  }
  cout << hop << endl;
}



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

n = int(input())
a = [int(input()) for i in range(n)]    
c,s=1,a[0]
while s != 2 and c < n: 
    c,s = c+1, a[s-1]
print(c if c<n else -1)

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> N;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int> buttom(N);
      |     ^~~~~~
a.cc:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> buttom(N);
      |            ^~~
a.cc:8:16: error: 'buttom' was not declared in this scope
    8 |         cin >> buttom.at(i);
      |                ^~~~~~
a.cc:14:13: error: 'buttom' was not declared in this scope
   14 |         if (buttom.at(push) == 2){
      |             ^~~~~~
a.cc:15:13: error: 'cout' was not declared in this scope
   15 |             cout << j + 1 << endl;
      |             ^~~~
a.cc:15:30: error: 'endl' was not declared in this scope
   15 |             cout << j + 1 << endl;
      |                              ^~~~
a.cc:21:17: error: 'cout' was not declared in this scope
   21 |                 cout << -1 << endl;
      |                 ^~~~
a.cc:21:31: error: 'endl' was not declared in this scope
   21 |                 cout << -1 << endl;
      |                               ^~~~
a.cc:24:6: error: expected '}' at end of input
   24 |     }
      |      ^
a.cc:1:12: note: to match this '{'
    1 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main() {
	int N, a;
	int flg = 1;
	cin >> N;

	vector<int> buttonStream(N);

	for ( int i = 0 ; i < N ; i++ ) {
		buttonStream.at(i) = a - 1;
	}

	int now = 0, c = 0;

	for ( ; ; ){

		if ( now == 1) {
			cout << c << endl;
			break;
		}

		if (c > = N ) {
			cout << -1 << endl;
			break;
		}

		c++;
		now = buttonStream.at(now);
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:25: error: expected primary-expression before '=' token
   38 |                 if (c > = N ) {
      |                         ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:6:17: error: 'N' was not declared in this scope
    6 |   vector<int> a(N);
      |                 ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:6:17: error: 'N' was not declared in this scope
    6 |   vector<int> a(N);
      |                 ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000000000000LL
#define MOD 1000000007
#define writeln(n) cout<<n<<endl;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main()
{
    int n;　//鳩の巣原理よりN+1回押すと絶対1つ以上かぶってる
    cin >> n;
    int ans = 0;
    bool used[n] = {0};
    int a[n];
    int now = 0;
    for(int i = 0; i < n; ++i){
        int b; cin >> b;
        a[i] = b - 1;
    }
    while(1){
        ++ans;
        if(a[now] == 1){
            cout << ans << endl;
            break;
        }else if(used[a[now]]){
            cout << -1 << endl;
            break;
        }else{
            used[a[now]] = 1;
            now = a[now];
        }
    }
}

Compiler output:
a.cc:29:11: error: extended character 　 is not valid in an identifier
   29 |     int n;　//鳩の巣原理よりN+1回押すと絶対1つ以上かぶってる
      |           ^
a.cc: In function 'int main()':
a.cc:29:11: error: '\U00003000' was not declared in this scope
   29 |     int n;　//鳩の巣原理よりN+1回押すと絶対1つ以上かぶってる
      |           ^~
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n
  vector<int> a(n);
  FDS(i,n){
    cin>>a[i];
  }
  int t;
  FDS(i,n){
    if(a[t]==2){
      cout<<i<<endl;
      return 0;
    }
    t=a[t]-1;
  }
  cout<<-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: expected ';' before 'vector'
   16 |   cin>>n
      |         ^
      |         ;
   17 |   vector<int> a(n);
      |   ~~~~~~ 
a.cc:19:10: error: 'a' was not declared in this scope
   19 |     cin>>a[i];
      |          ^
a.cc:23:8: error: 'a' was not declared in this scope
   23 |     if(a[t]==2){
      |        ^
a.cc:27:7: error: 'a' was not declared in this scope
   27 |     t=a[t]-1;
      |       ^
Language: C++

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  
  for(int i=0; i < n ; i++) {
    cin >> v.at(i);
  }
  
  int j = 0;
  int i = 0;
  
  while(i < n) {
    if(v.at(j) != 2){
      j = v.at(j)
    }
    i++
      if(v.at(j) == 2){
        cout << i << endl;
      }
  }
  cout << "-1" << endl;
}  


Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: expected ';' before '}' token
   18 |       j = v.at(j)
      |                  ^
      |                  ;
   19 |     }
      |     ~             
a.cc:20:8: error: expected ';' before 'if'
   20 |     i++
      |        ^
      |        ;
   21 |       if(v.at(j) == 2){
      |       ~~
Language: C++

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

int main() {
    int n;
    cin >> n;

    vector<int> vec(n + 1);
    vec.at(0) = 0;
    for (int i = 1; i < n + 1; i++) cin >> vec.at(i);

    int b = 1;
    for (int i = 1; i < n + 1; i++) {
        b = vec.at(b)
        if (b == 2) {
            cout << i << endl;
            break;
        }
    }

    if (i == n) cout << -1 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: expected ';' before 'if'
   14 |         b = vec.at(b)
      |                      ^
      |                      ;
   15 |         if (b == 2) {
      |         ~~            
a.cc:21:9: error: 'i' was not declared in this scope
   21 |     if (i == n) cout << -1 << endl;
      |         ^
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 s = 0, b = 0, c;
  while(s != 2){
     if(a.at(s)== -1){
       b = -1;
       break;
     }
    c = s
    s = a.at(s);
    a.at(c) = -1;
   b++;
  }
cout << b << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:10: error: expected ';' before 's'
   18 |     c = s
      |          ^
      |          ;
   19 |     s = a.at(s);
      |     ~
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); 
  }
int s = 0, b = 0;
  while(s != 2){
     if(a.at == -1){
       b = -1;
       break;
     }
    s = a.at(s);
    a.at(s) = -1;
   b++;
  }
cout << b << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: no match for call to '(std::vector<int>) (int&)'
   10 |    cin >> a(i);
      |           ~^~~
a.cc:14:14: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator=='
   14 |      if(a.at == -1){
      |         ~~~~ ^~ ~~
      |           |     |
      |           |     int
      |           <unresolved overloaded function type>
Language: C++

#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 s = 1, cnt = 1, tmp;
  while(s==2) {
    if(A[s]==-1) {cout << -1 << "\n"; return 0;}
    tmp = s-1;
    s = A[s-1];
    A[tmp] = -1;
    cnt++;
  }
  cout << cnt << "\n";
}
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected initializer before 'for'
    7 |   for (int i = 0; i<N; i++) cin >> A[i];
      |   ^~~
a.cc:7:19: error: 'i' was not declared in this scope
    7 |   for (int i = 0; i<N; i++) cin >> A[i];
      |                   ^
a.cc:10:8: error: 'A' was not declared in this scope
   10 |     if(A[s]==-1) {cout << -1 << "\n"; return 0;}
      |        ^
a.cc:12:9: error: 'A' was not declared in this scope
   12 |     s = A[s-1];
      |         ^
Language: Java

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 cnt = 0;
        int s = 0;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        
        for(int i=0; i<a.length(); i++){
            s = a[s];
            cnt++;
            if(s == 2){
                System.out.println(cnt);
                return;
            }
        }
        System.out.println("-1");
    }
}

Compiler output:
Main.java:13: error: cannot find symbol
        for(int i=0; i<a.length(); i++){
                        ^
  symbol:   method length()
  location: variable a of type int[]
1 error
Language: Java

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 cnt = 0;
        int s = 0;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        
        for(int i=0; i<a.lenth(); i++){
            s = a[s];
            cnt++;
            if(s == 2){
                System.out.println(cnt);
                return;
            }
        }
        System.out.println("-1");
    }
}

Compiler output:
Main.java:6: error: cannot find symbol
        int[] a = new Int[n];
                      ^
  symbol:   class Int
  location: class Main
Main.java:13: error: cannot find symbol
        for(int i=0; i<a.lenth(); i++){
                        ^
  symbol:   method lenth()
  location: variable a of type int[]
2 errors
Language: C++


#include <bits/stdc++.h>
using namespace std;
int main(){
	int i, N;
	int k;
	int x;
	cin >> N;
	vector<int> vec(N);
	for (int i=0;i<N;i++){
		cin >> vec.at(i);
	}
	// 入力はすべてここで終わり。
	k = vec.at(0) ;
	if (k == 2){
		cout <<"1" <<endl;
	}//〇
	else if (k == 1){
		cout << "-1" <<endl;
	}//〇

	else {
		for (int i= 2; i =< N ; i++){
			
		vec.at(0) = 0;
			x = vec.at(k-1); //ｘは次に光るボタン
			vec.at(k-1) == 0;//kのボタンを押して次に進んだので、k-1番目の配列要素を0に更新

			if (x == 2 ){//終わるパタン
				cout << i <<endl;
				break; // 〇
			}
			else if (x == 0){//抜け出せないパタン
				cout << "-1" <<endl;
			break; //〇
			}
			else if (x==k){//同じ光っちゃった
			cout << "-1" <<endl;
			break;
				//〇
			}
				k = x;
		} 
	}	

}	
				//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
				//ただし2のスイッチは配列的には1番目
				//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
				//これは押した後に光った番号。すなわち押し他番号をｎとして
				//vec.at n がn+1の時にループが起こるってこｔ
				///これもしかして""で囲まなきゃダメ解けない？いいえ。	
			///1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。/これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。/n=xでｘの値を代入しなおすことが出来たはず。


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


#include <bits/stdc++.h>
using namespace std;
int main(){
	int i, N;
	int k;
	int x;
	cin >> N;
	vector<int> vec(N);
	for (int i=0;i<N;i++){
		cin >> vec.at(i);
	}
	// 入力はすべてここで終わり。
	k = vec.at(0) ;
	if (k == 2){
		cout <<"1" <<endl;
	}//〇
	else if (k == 1){
		cout << "-1" <<endl;
	}//〇

		vec.at(0) = 0;
	else {
		for (int i= 2; i < N ; i++){
			
			x = vec.at(k-1); //ｘは次に光るボタン
			vec.at(k-1) == 0;//kのボタンを押して次に進んだので、k-1番目の配列要素を0に更新

			if (x == 2 ){//終わるパタン
				cout << i <<endl;
				break; // 〇
			}
			else if (x == 0){//抜け出せないパタン
				cout << "-1" <<endl;
			break; //〇
			}
			else if (x==k){//同じ光っちゃった
			cout << "-1" <<endl;
			break;
				//〇
			}
				k = x;
		} 
	}	

}	
				//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
				//ただし2のスイッチは配列的には1番目
				//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
				//これは押した後に光った番号。すなわち押し他番号をｎとして
				//vec.at n がn+1の時にループが起こるってこｔ
				///これもしかして""で囲まなきゃダメ解けない？いいえ。	
			///1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。/これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。/n=xでｘの値を代入しなおすことが出来たはず。


Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'else' without a previous 'if'
   23 |         else {
      |         ^~~~
Language: C++


#include <bits/stdc++.h>
using namespace std;
int main(){
	int i, N;
	int k;
	cin >> N;
	vector<int> vec(N);
	for (int i=0;i<N;i++){
		cin >> vec.at(i);
	}
	//forは一回ここで終わった
	int k; 
	k = vec.at(0) ;
	if (k == 2){
		cout <<"1" <<endl;
	}
	else if (k == 1){
		cout << "-1" <<endl;
	}
	else {
		vec.at(0) = 0;
		for (int i= 2; i < N+2 ; i++){

			x = vec.at(k-1); //ｘは次に光るボタン

			if (x == 2 ){
				cout << i <<endl;
				break;
			}
			else if (x == 0){
				cout << "-1" <<endl;
			break;
			}
			else if (x==k){
			cout << "-1" <<endl;
			break;
				
			}
			else {
				vec.at(x) == 0;
				k = x;
			}
		} 
	}	

}	
				//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
				//ただし2のスイッチは配列的には1番目
				//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
				//これは押した後に光った番号。すなわち押し他番号をｎとして
				//vec.at n がn+1の時にループが起こるってこｔ
				///これもしかして""で囲まなきゃダメ解けない？いいえ。	
			///1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。/これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。/n=xでｘの値を代入しなおすことが出来たはず。


Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: redeclaration of 'int k'
   13 |         int k;
      |             ^
a.cc:6:13: note: 'int k' previously declared here
    6 |         int k;
      |             ^
a.cc:25:25: error: 'x' was not declared in this scope
   25 |                         x = vec.at(k-1); //ｘは次に光るボタン
      |                         ^
Language: C++


#include <bits/stdc++.h>
using namespace std;
int main(){
	int i, N;
	cin >> N;
	vector<int> vec(N);
	for (int i=0;i<N;i++){
		cin >> vec.at(i);
	}
	//forは一回ここで終わった
	int k; 
	k = vec.at(0) ;//1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。
	if (k == 2){
		cout <<"1" <<endl;
	}
		else if (k == 1){
			cout << "-1" <<endl;
		}
		else {
			vec.at(0) = 0;//これもしかして""で囲まなきゃダメ解けない？いいえ。	
			//これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。
			for (int i= 2; i < N+2 ; i++){
				//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
				//ただし2のスイッチは配列的には1番目
				//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
				//これは押した後に光った番号。すなわち押し他番号をｎとして
				//vec.at n がn+1の時にループが起こるってこｔ
				int x;
				x = vec.at(k-1);

				if (x == 2 ){
					cout << i <<endl;
					break;//これはおｋ
				}
				else if (x == 0){
					cout << "-1" <<endl;
					break;//これもおｋ
				}
				else if (x==k){
					cout << "-1" <<endl;
					break;
				}
				else {
					vec.at(x) == 0;
					k = x;
				}
			} //n=xでｘの値を代入しなおすことが出来たはず。
		}	

	



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


#include <bits/stdc++.h>
using namespace std;
int main(){
	int i, N;
	cin >> N;
	vector<int> vec(N);
	for (int i=0;i<N;i++){
		cin >> vec.at(i);
	}

	int k; 
	k = vec.at(0) ;//1のボタンを押した後に光るボタンがn。それは配列的にはn-1番目の要素。
	if (k == "2"){
		cout <<"1" <<endl;
	
	else if (k == "1"){
		cout << "-1" <<endl;
	}
		else {
	vec.at(0) = 0;//これもしかして""で囲まなきゃダメ解かないよね	
 //これですべての入力を受け取る 入力を受け取ったら値を0にして、次0に当たったら2はつかないってことだ。
	for (int i= 2; i < N+2 ; i++){
//最初1のスイッチを押したとき2が光れば、次は2のスイッチを押す
//ただし2のスイッチは配列的には1番目
//1が光った場合一生2を押すことにはならないのでしっぱい -1を出力
//これは押した後に光った番号。すなわち押し他番号をｎとして
//vec.at n がn+1の時にループが起こるってこｔ
	int x;
	x = vec.at(n-1);

	if (x == "2" ){
		cout << i <<endl;
		break;//これはおｋ
	}
	else if (x == "0"){
		cout << "-1" <<endl;
		break;//これもおｋ
	}
	else if (x==n){
		cout << "-1" <<endl;
		break;
	}
	else {
		vec.at(x) == "0";
	n = x;
	}
	} //n=xでｘの値を代入しなおすことが出来たはず。
		}	
	
}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |         if (k == "2"){
      |             ~~^~~~~~
a.cc:17:9: error: expected '}' before 'else'
   17 |         else if (k == "1"){
      |         ^~~~
a.cc:14:22: note: to match this '{'
   14 |         if (k == "2"){
      |                      ^
a.cc:17:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   17 |         else if (k == "1"){
      |                  ~~^~~~~~
a.cc:30:20: error: 'n' was not declared in this scope
   30 |         x = vec.at(n-1);
      |                    ^
a.cc:32:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   32 |         if (x == "2" ){
      |             ~~^~~~~~
a.cc:36:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   36 |         else if (x == "0"){
      |                  ~~^~~~~~
a.cc:45:27: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   45 |                 vec.at(x) == "0";
      |                 ~~~~~~~~~~^~~~~~
Language: Java

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[]a = new int[N+1];
		for(int i = 1; i <= N; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		boolean[] b = new boolean[N+1];
		
		int i = 1;
		b[1] = true;
		int count = 0;
		
		while(true) {
			if(b[i] == false) {
				count++;
				b[i] = true;
				if(a[i] == 2) {
					break;
				}
				i = a[i];
			}else {
				count = -1;
				break;
			}
		}
		System.out.println(count);
	}
}

Compiler output:
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

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

int main() {
  int N,;
  vector<int> v(N);
  for(int i=0; i<N; i++) {
    cin >> v[i];
    v[i]--;
  }
  for(int i=0, next=v[0]; i<N; i++) {
    if(v[0]==1) {
      cout << i+1 << endl;
      return 0;
    }
    next=v[next];
  }
  cout << -1 << 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<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	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;
		}
		if (c >= n)
		{
			cout << "-1" << endl;
			break;
		}
		c++;
		now = v[now];
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'cin' was not declared in this scope
   11 |         cin >> n;
      |         ^~~
a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    5 | #include<iomanip>
  +++ |+#include <iostream>
    6 | using namespace std;
a.cc:25:25: error: 'cout' was not declared in this scope
   25 |                         cout << c << endl;
      |                         ^~~~
a.cc:25:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:25: error: 'cout' was not declared in this scope
   30 |                         cout << "-1" << endl;
      |                         ^~~~
a.cc:30:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

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

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

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;
    }
    if (c >= n) {
      cout << -1 << endl;
      break;
    }
    c++;
    now = v.at(now);
  }
}

Compiler output:
a.cc:9:5: error: extended character − is not valid in an identifier
    9 |     z−−;
      |     ^
a.cc:9:5: error: extended character − is not valid in an identifier
a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
    4 |   cin >> N;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> v;
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> v;
      |          ^~~
a.cc:6:23: error: 'n' was not declared in this scope
    6 |   for (int i = 0; i < n; i++) {
      |                       ^
a.cc:9:5: error: 'z\U00002212\U00002212' was not declared in this scope
    9 |     z−−;
      |     ^~~
a.cc:10:5: error: 'v' was not declared in this scope
   10 |     v.push_back(z);
      |     ^
a.cc:15:7: error: 'cout' was not declared in this scope
   15 |       cout << c << endl;
      |       ^~~~
a.cc:15:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:20: error: 'endl' was not declared in this scope
   15 |       cout << c << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:18:14: error: 'n' was not declared in this scope
   18 |     if (c >= n) {
      |              ^
a.cc:19:7: error: 'cout' was not declared in this scope
   19 |       cout << -1 << endl;
      |       ^~~~
a.cc:19:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:21: error: 'endl' was not declared in this scope
   19 |       cout << -1 << endl;
      |                     ^~~~
a.cc:19:21: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:23:11: error: 'v' was not declared in this scope
   23 |     now = v.at(now);
      |           ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:13:8: error: 'i' was not declared in this scope
   13 |   for (i = 0; i >= 0; i++) {
      |        ^
Language: C++

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

int main() {
  int N, b;
  b = 0;
  cin >> N;
  vector<int> a(N);
  
  for (int i = 0; i < N, i++) {
    cin >> a.at(i);
  }
  int i = 1;
  while () {
    b = a.at(b);
    if (b == 1){
      cout << i << endl;
      break;
    }else if (b == 0){
      cout << -1 << endl;
      break;
    }
    i++;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:29: error: expected ';' before ')' token
   10 |   for (int i = 0; i < N, i++) {
      |                             ^
      |                             ;
a.cc:14:10: error: expected primary-expression before ')' token
   14 |   while () {
      |          ^