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

#include<iostream>
#include<vecotr>
#include<algorithm>
using namespace std;

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

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

#include<stdio.h>
const int maxn=1e5+6;
int a[maxn],b[maxn],c[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		a[i]=i;
	}
	int k=1,sum=1,flag=0;
	c[1]=1;
	while(n--)
	{
		c[b[k]]=1;
		k=b[a[k]];
		sum++;
		if(k==2)
		{
			if(c[b[2]]==1)
			{
				printf("%d",sum-1);
				flag=1;
				break;	
			}
		}
	}
	if(flag==0) printf("-1");
	return 0;
}

Compiler output:
main.c:3:5: error: variably modified 'a' at file scope
    3 | int a[maxn],b[maxn],c[maxn];
      |     ^
main.c:3:13: error: variably modified 'b' at file scope
    3 | int a[maxn],b[maxn],c[maxn];
      |             ^
main.c:3:21: error: variably modified 'c' at file scope
    3 | int a[maxn],b[maxn],c[maxn];
      |                     ^
Language: C++

#include<iostream>
using namespace std;
int c[100005];
int time(0);
bool win(long int a,long int *b)
{
	time++;
	if(b[a]==2)
	return true;
	else
	if(c[a]!=1)
	{
		c[a]=1;
		a=b[a];
		win(a,b);
	}
	else
	return false;
}
int main()
{
	int a;
	long int b[100005];
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>b[i];
	}
	if(win(1,b))
	cout<<time;
	else
	cout<<"-1";
	return 0;
	
}

Compiler output:
a.cc:4:9: error: 'int time' redeclared as different kind of entity
    4 | int time(0);
      |         ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
    7 |         time++;
      |         ^~~~
a.cc:7:13: error: lvalue required as increment operand
    7 |         time++;
      |             ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
int c[100005];
static int time=0;
bool win(long int a,long int *b)
{
	time++;
	if(b[a]==2)
	return true;
	else
	if(c[a]!=1)
	{
		c[a]=1;
		a=b[a];
		win(a,b);
	}
	else
	return false;
}
int main()
{
	int a;
	long int b[100005];
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>b[i];
	}
	if(win(1,b))
	cout<<time;
	else
	cout<<"-1";
	return 0;
	
}

Compiler output:
a.cc:4:12: error: 'int time' redeclared as different kind of entity
    4 | static int time=0;
      |            ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
    7 |         time++;
      |         ^~~~
a.cc:7:13: error: lvalue required as increment operand
    7 |         time++;
      |             ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
int c[100005];
int time=0;
bool win(long int a,long int *b)
{
	time++;
	if(b[a]==2)
	return true;
	else
	if(c[a]!=1)
	{
		c[a]=1;
		a=b[a];
		win(a,b);
	}
	else
	return false;
}
int main()
{
	int a;
	long int b[100005];
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>b[i];
	}
	if(win(1,b))
	cout<<time;
	else
	cout<<"-1";
	return 0;
	
}

Compiler output:
a.cc:4:5: error: 'int time' redeclared as different kind of entity
    4 | int time=0;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
    7 |         time++;
      |         ^~~~
a.cc:7:13: error: lvalue required as increment operand
    7 |         time++;
      |             ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
int c[100005];
int time=0;
bool win(long int a,long int *b)
{
	time++;
	if(b[a]==2)
	return true;
	else
	if(c[a]!=1)
	{
		c[a]=1;
		a=b[a];
		win(a,b);
	}
	else
	return false;
}
int main()
{
	int a;
	long int b[100005];
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>b[i];
	}
	if(win(1,b))
	cout<<time;
	else
	cout<<"-1";
	
	
}

Compiler output:
a.cc:4:5: error: 'int time' redeclared as different kind of entity
    4 | int time=0;
      |     ^~~~
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'bool win(long int, long int*)':
a.cc:7:9: warning: ISO C++ forbids incrementing a pointer of type 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} [-Wpointer-arith]
    7 |         time++;
      |         ^~~~
a.cc:7:13: error: lvalue required as increment operand
    7 |         time++;
      |             ^~
a.cc:19:1: warning: control reaches end of non-void function [-Wreturn-type]
   19 | }
      | ^
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_SIZE 100001

int seq[MAX_SIZE];
int main()
{
	int n;
	while(scanf_s("%d",&n)!=-1){

		memset(seq,0,sizeof(seq));
		for(int i=1;i<=n;i++){
			scanf_s("%d",&seq[i]);
		}

		int step=1;
		int num=seq[1];
		int seq_n=1;
		while(seq[num]!=num){
			seq_n=num;
			step++;
			if(seq[seq_n]==2){
				printf("%d\n",step);
				break;
			}
			else{
				if(seq_n==num){
					printf("-1\n");
					break;
				}
				else{
					num=seq[seq_n];
				}
			}
		}
	}
	return 0;
}



Compiler output:
main.c: In function 'main':
main.c:10:15: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   10 |         while(scanf_s("%d",&n)!=-1){
      |               ^~~~~~~
      |               scanf
Language: C++


#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include<set>
using namespace std;
typedef long long ll;
const int maxn=int(1e5 + 5);
int arr[maxn];
set<int>S;
int main()
{
	S.clear(); int sizes = 0;
	int n; cin >> n;
	for (int i = 1; i <= n; i++)scanf_s("%d", &arr[i]);
	int tmp = 1;
	int ans = 0,k=1;
	while (1) {
		 tmp = arr[tmp];
		 if (tmp == 2) { ans = k; break; }
		 S.insert(tmp); sizes++;
		 if (S.size() < sizes) { ans = -1; break; }
		 k++;
	}
	cout << ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:37: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   20 |         for (int i = 1; i <= n; i++)scanf_s("%d", &arr[i]);
      |                                     ^~~~~~~
      |                                     scanf
Language: C

#include<stdio.h>
int main()
{
	int const MAXV=100000;
	int input=0;
	do{scanf("%d",&input);}while(input<2);
	int buttons[MAXV]={0};
	int times=1;
	for(int i=0;i<input;i++)
	{
		scanf("%d",&buttons[i]);
	}
	int i=buttons[0];
	while(times<input)
	{
		i=buttons[i-1];
		times++;
		
		if(i==2)
			break;
		
	}
	if(times<input)
		printf("%d",times);
	else
		printf("-1");
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:27: error: variable-sized object may not be initialized except with an empty initializer
    7 |         int buttons[MAXV]={0};
      |                           ^
Language: C

#include<stdio.h>

int main()
{
	int N,a;
	scanf_s("%d", &N);
	int n[100000];

	for (int i = 0; i < N; i++)
	{
		scanf_s("%d", &n[i]);

		if (n[i] == 2)
		{
			printf("%d", i);
			return 0;
		}
	}
	printf("-1");
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    6 |         scanf_s("%d", &N);
      |         ^~~~~~~
      |         scanf
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int a[n];
    int b,c,d;
    c=1;
    d=0;

    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    b=a[0];
    for(int i=0;i<n;i++){
        if(b==2){d=c;}
        else{c++;}
        b=a[b];
    }
    if(d==0){printf("-1");}
    else{printf("%d",d)}
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:24: error: expected ';' before '}' token
   25 |     else{printf("%d",d)}
      |                        ^
      |                        ;
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int a[n];
    int b,c;
    c=1;

    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    b=a[0];
    for(int i=0;i<n;i++){
        if(b==2){printf("c")}
        else if(b>n){printf("-1");}
        else{c++;}
        b=a[b];
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:29: error: expected ';' before '}' token
   19 |         if(b==2){printf("c")}
      |                             ^
      |                             ;
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

int main(void){
    cin >> n;
    int a[n];
    int b,c;
    c=1;

    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    b=a[0];
    for(int i=0;i<n;i++){
        if(b==2){printf("c")}
        else if(b>n){printf("-1");}
        else{c++;}
        b=a[b];
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: 'n' was not declared in this scope
    8 |     cin >> n;
      |            ^
a.cc:14:16: error: 'a' was not declared in this scope
   14 |         cin >> a[i];
      |                ^
a.cc:16:7: error: 'a' was not declared in this scope
   16 |     b=a[0];
      |       ^
a.cc:18:29: error: expected ';' before '}' token
   18 |         if(b==2){printf("c")}
      |                             ^
      |                             ;
Language: C++

#include<stdio.h>
#include<vector>
#include<iostream> //c++
/*
int main(){
	int a=0;
	char A[5];
	for (int i = 0; i < 5; i++) {
		scanf("%c\n", &A[i]);
	}
	
	for(int i = 0; i < 5; i++) {
		if (A[i] =='A' &&A[i + 1]=='C') {
			a = 1;
		
		}
	}
	if (a == 1) {
		printf("Yes");

	}
	else {
		printf("No");
	}
}*/

using namespace std;
int main() {
	int g;
	int  N,Num=0;
	vector<int>a;
	scanf_s("%d", &N);
	for (int i = 0; i < N;i++) {

		cin >> g;

		a.push_back(g);
	

	}
	int p=1;
	while (true) {

		p = a[p];
			Num++;
			if (p == 2) {
				break;
			}
	}
	printf("%d", Num);
	

}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   32 |         scanf_s("%d", &N);
      |         ^~~~~~~
      |         scanf
Language: C++

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

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

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

Compiler output:
a.cc:4:6: error: expected initializer before '==' token
    4 | int c==-1;
      |      ^~
a.cc: In function 'int main()':
a.cc:9:13: error: 'c' was not declared in this scope
    9 |     if(b==2)c=i;
      |             ^
a.cc:11:9: error: 'c' was not declared in this scope
   11 |   cout<<c<<endl;
      |         ^
Language: C++

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

int main()
{
    int n;  cin >> n;
    int n[a];
    rep(i,n)  cin >> a[i];

    int t = a[0] - 1;
    int ans = 0;

    rep(i,n) {
        if (t == 1) {
            ans++;
            cout << ans << endl;
            break;
        }
        ans++;
        t = a[t] - 1;
        if (i == n-1)  cout << -1 << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:11: error: 'a' was not declared in this scope
    8 |     int n[a];
      |           ^
Language: C++

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

int main(){
  int N;
  int count = 0;
  int temp0, temp1 = 1, 1;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  while (temp1 != -1 || temp1 != 2) {
    temp1 = a.at(temp0);
    a.at(temp0) = -1;
    temp0 = temp1;
    count++;
    if (temp1 == -1)
      count = -1;
  }
  cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:25: error: expected unqualified-id before numeric constant
    7 |   int temp0, temp1 = 1, 1;
      |                         ^
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 i = 1;
  int cnt = 0;
  bool b = false;
  while(c < n){
    cnt++;
    i = a.at(i-1);
    if (i == n-1) {
      b = true;
      break;
    }
  }
  
  if(b) cout << cnt << endl;
  else cout << -1 << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'c' was not declared in this scope
   15 |   while(c < n){
      |         ^
Language: C++

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

int main() {
    int N;
    cin >> N;
    vector<int> a(n);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    bool flag = true;
    int cnt = 0;
    int tmp = 0;
    while (flag && cnt < N){
        cnt++;
        if (a[tmp - 1] == 2){
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << -1 << endl;
    }
    else{
        cout << cnt << endl;
    }
}


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

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

int main() {
    int N;
    cin >> N;
    vector<int> a(n);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    bool flag = true;
    int cnt = 0;
    int tmp = 0;
    while (flag && cnt < N){
        cnt++
        if (a[tmp - 1] == 2){
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << -1 << endl;
    }
    else{
        cout << cnt << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:19: error: 'n' was not declared in this scope
   10 |     vector<int> a(n);
      |                   ^
a.cc:18:14: error: expected ';' before 'if'
   18 |         cnt++
      |              ^
      |              ;
   19 |         if (a[tmp - 1] == 2){
      |         ~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'whlie' was not declared in this scope
   12 |   whlie(true){
      |   ^~~~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'whlie' was not declared in this scope
   12 |   whlie(1){
      |   ^~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:3: error: 'whlie' was not declared in this scope
   12 |   whlie(){
      |   ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin>>n;
  vector<int> l(n),r(n);
  rep(i,n){
    cin>>l.at(i);
  }
  r.at(0) = l.at(0);
  if(l.at(0)==2){
    cout<<2;
    return 0;
  }
  int min=1;
 for(int j=1; j<n; j++){
    r.at(j) = l.at(r.at(j-1));
   min++;
   if(r.at(j)==2){
     cout<<min;
     return 0;
   }  
 }
  if(min==n){
    cout<<-1;
}

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

#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    int a[100010];
    for(int i = 0; i < n; ++i) cin >> a[i];
    
    int counter = 1;
    while(a[i] != 2) {
        int i = 0;
        if(a[i] == 1) {
            counter = -1;
            break;
        }
        
        i = a[i] - 1;
        ++counter;
    }
    
    cout << counter << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: 'i' was not declared in this scope
   11 |     while(a[i] != 2) {
      |             ^
Language: C++

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

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


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

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

int main(){
  int N,s,result=0;
  cin >> N;
  
  vector<int> button(N,0);
  button.at(0) = 1;
  
  for(int i=0;i<N;i++){
    cin >> s;
    
    if(button.at(i) == 1){
    button.at(i) = 0;
    button.at(s-1) = 1;
    result++;
    }
  }
      
    if(button.at(1) == 1){
      cout << result <<endl;
      break;
    }
  if(button.at(1) != 1)
      cout <<-1 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:7: error: break statement not within loop or switch
   23 |       break;
      |       ^~~~~
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 i=0;
  while (int a != 2) {
    a = vec.at(a);
    ++i;
    if (i>N) {
      break;
    }
  }
  if (i <= N-1) {
  cout << i << endl;
  }else{
    cout << -1 << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:16: error: expected initializer before '!=' token
   12 |   while (int a != 2) {
      |                ^~
a.cc:12:15: error: expected ')' before '!=' token
   12 |   while (int a != 2) {
      |         ~     ^~~
      |               )
a.cc:12:16: error: expected primary-expression before '!=' token
   12 |   while (int a != 2) {
      |                ^~
Language: C++

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

int main() {
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++) {
        cin>>a[i];
        a[i]--;
    }
    int vis[n]{};
    int p=0;
    int cnt=0;
    while (1) {
        if (vis[i]) {
            cout<<-1<<endl;
            return 0;
        }
        vis[p]=1;
        p=a[p];
        cnt++;
        if (p==1) {
            cout<<cnt<<endl;
            return 0;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'i' was not declared in this scope
   17 |         if (vis[i]) {
      |                 ^
Language: C++

#include <iostream>
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    int j = 1;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        j = a.at(j - 1);
        count++;
        if (j == 2)
            break;
    }
    if (count == N)
    {
        cout << -1 << "\n";
    }
    else
    {
        cout << count << "\n";
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'vector' was not declared in this scope
   11 |     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:11:12: error: expected primary-expression before 'int'
   11 |     vector<int> a(N);
      |            ^~~
a.cc:14:16: error: 'a' was not declared in this scope
   14 |         cin >> a.at(i);
      |                ^
a.cc:20:13: error: 'a' was not declared in this scope
   20 |         j = a.at(j - 1);
      |             ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;


int visit(int cnt, int idx, vector<int> &a, vector<bool> &v){
  if(cnt >= N) return -1;
  else if(v[a[idx]]) return -1;
  else if(a[idx] == 2) return cnt;
  else{
    v[idx] = true;
    return visit(cnt + 1, a[idx], a, v);
  }
}

int main(void) {
  int N;
  cin >> N;
  
  vector<int> a(N);
  vector<bool> v(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  cout << visit(1, a[0], a, v);
}

Compiler output:
a.cc: In function 'int visit(int, int, std::vector<int>&, std::vector<bool>&)':
a.cc:8:13: error: 'N' was not declared in this scope
    8 |   if(cnt >= N) return -1;
      |             ^
a.cc:15:1: warning: control reaches end of non-void function [-Wreturn-type]
   15 | }
      | ^
Language: C++

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

int main () {
  int N, c = 1;
  bool b = false;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  int p = vec.at(0);
  if (p == 2) {
    cout << 1;
  }
  else {
    for (int i = 0; i < N - 1; i++) {
        p = vec.at(p);
        c++;
        if (p == 2) {
          cout << c;
          b = true;
          break;
        }
      }
    if (!b){
      cout << -1;
    }
}

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

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:13:19: error: expected primary-expression before ';' token
   13 |       if(int i=0; ;i++){
      |                   ^
a.cc:13:18: error: expected ')' before ';' token
   13 |       if(int i=0; ;i++){
      |         ~        ^~
      |                  )
a.cc:13:20: error: 'i' was not declared in this scope
   13 |       if(int i=0; ;i++){
      |                    ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: expected primary-expression before ';' token
   13 |       if(int i=0;;i++){
      |                  ^
a.cc:13:18: error: expected ')' before ';' token
   13 |       if(int i=0;;i++){
      |         ~        ^
      |                  )
a.cc:13:19: error: 'i' was not declared in this scope
   13 |       if(int i=0;;i++){
      |                   ^
Language: C++

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

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


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

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    vector<int> flag(N+1);
    rep(i,N){
        cin >> a[i+1];
    }
    int cnt = 0;
    flag[1] = 1;
    for(int i=1;i<=N;i++){
        cnt++;
        if(flag(a[i])){
            cout << -1 << endl;
            return 0;
        }
        if(a[i]==2){
            cout << cnt << endl;
            return 0;
        }
        flag(a[i])=1;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:16: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   20 |         if(flag(a[i])){
      |            ~~~~^~~~~~
a.cc:28:13: error: no match for call to '(std::vector<int>) (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   28 |         flag(a[i])=1;
      |         ~~~~^~~~~~
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N), b;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int light_on = 0, cnt = 0;
  while(cnt < 10**6){
    light_on = a[light_on];
    cnt += 1
    if(light_on == 0){
      cout << -1;
    else if(light_on == 1);
      cout << cnt;
    }
  }
}      

Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: invalid type argument of unary '*' (have 'int')
   13 |   while(cnt < 10**6){
      |                  ^~
a.cc:15:13: error: expected ';' before 'if'
   15 |     cnt += 1
      |             ^
      |             ;
   16 |     if(light_on == 0){
      |     ~~
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 count=0, first=1;
  while (true){
    count++;
    first = vec.at(first-1)
    if (first==2){
      cout<<count<<endl;
    }
    if (first==vec.at(0)){
      cout << -1<<endl;
      break;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:28: error: expected ';' before 'if'
   14 |     first = vec.at(first-1)
      |                            ^
      |                            ;
   15 |     if (first==2){
      |     ~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,c_point=1,end=0,count=0;
  cin>>n;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++)cin>>a.at(i);
  while(c_point!=2&&c_point!=0)){
    int x=c_point;
    c_point=a.at(c_point);
    a.at(x)=0;
    count++;
  }
  if(c_point==2)cout<<count<<"/n";
  if(c_point==0)cout<<-1<<"/n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:32: error: expected primary-expression before ')' token
    9 |   while(c_point!=2&&c_point!=0)){
      |                                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,c_point=1,end=0,count=0;
  cin>>n;
  vector<int> a(n+1);
  for(int i=1;i<=n;i++)cin>>a.at(i);
  while(!(c_point==2||c_point==0);){
    int x=c_point;
    c_point=a.at(c_point);
    a.at(x)=0;
    count++;
  }
  if(c_point==2)cout<<count<<"/n";
  if(c_point==0)cout<<-1<<"/n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:34: error: expected ')' before ';' token
    9 |   while(!(c_point==2||c_point==0);){
      |        ~                         ^
      |                                  )
a.cc:9:35: error: expected primary-expression before ')' token
    9 |   while(!(c_point==2||c_point==0);){
      |                                   ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:24: error: expected ';' before 'if'
   16 |         sv = std.at(sv)
      |                        ^
      |                        ;
   17 |                 if(sv == 2)
      |                 ~~      
a.cc:22:17: error: 'else' without a previous 'if'
   22 |                 else if(j == N - 1){
      |                 ^~~~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = n; i > 0; i--)
#define rep3(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep4(i, s, e) for (int i = (e); i < (int)(s); i--)

int main() {
    int n;
    cin >> n;
    int count = 0;
    int now = 1;
    vector<int> count(n);

    rep(i, n){
        cin >> count.at(i);
    }

    while (now != 2 && count < n) {
        now = count.at(now);
        count++;
        if (now == 2) {
            break;
        }
    }

    if (now != 2) {
        count = -1;
    }
    cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: conflicting declaration 'std::vector<int> count'
   14 |     vector<int> count(n);
      |                 ^~~~~
a.cc:12:9: note: previous declaration as 'int count'
   12 |     int count = 0;
      |         ^~~~~
a.cc:17:22: error: request for member 'at' in 'count', which is of non-class type 'int'
   17 |         cin >> count.at(i);
      |                      ^~
a.cc:21:21: error: request for member 'at' in 'count', which is of non-class type 'int'
   21 |         now = count.at(now);
      |                     ^~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = n; i > 0; i--)
#define rep3(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep4(i, s, e) for (int i = (e); i < (int)(s); i--)

int main() {
    int n;
    int count = 0;
    int now = 1;
    vector<int> count(n);

    rep(i, n){
        cin >> count.at(i);
    }

    while (now != 2 && count < n) {
        now = count.at(now);
        count++;
        if (now == 2) {
            break;
        }
    }

    if (now != 2) {
        count = -1;
    }
    cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: conflicting declaration 'std::vector<int> count'
   13 |     vector<int> count(n);
      |                 ^~~~~
a.cc:11:9: note: previous declaration as 'int count'
   11 |     int count = 0;
      |         ^~~~~
a.cc:16:22: error: request for member 'at' in 'count', which is of non-class type 'int'
   16 |         cin >> count.at(i);
      |                      ^~
a.cc:20:21: error: request for member 'at' in 'count', which is of non-class type 'int'
   20 |         now = count.at(now);
      |                     ^~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = n; i > 0; i--)
#define rep3(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep4(i, s, e) for (int i = (e); i < (int)(s); i--)

int main() {
    int n;
    int count = 0;
    int now = 1;
    vector<int> count(n);

    rep(i, n){
        cin >> count.at(i);
    }

    while (now != 2 && count < n) {
        now = count.at(now);
        count++;
        if (now == 2) {
            break;
    }

    if (now != 2) {
        count = -1;
    }
    cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: conflicting declaration 'std::vector<int> count'
   13 |     vector<int> count(n);
      |                 ^~~~~
a.cc:11:9: note: previous declaration as 'int count'
   11 |     int count = 0;
      |         ^~~~~
a.cc:16:22: error: request for member 'at' in 'count', which is of non-class type 'int'
   16 |         cin >> count.at(i);
      |                      ^~
a.cc:20:21: error: request for member 'at' in 'count', which is of non-class type 'int'
   20 |         now = count.at(now);
      |                     ^~
a.cc:30:2: error: expected '}' at end of input
   30 | }
      |  ^
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(){
    int a, b, c, d, f, m;
    cin>> a;
    int a1[a];
    for (int i = 0; i< a; i++){
        cin>> a1[i];
    }
    f = 0;
    b1 = false;
    m = 0;
    for (int i = 0; i< a; i++){

        if (a1[f] == 2){
            m++;
            b1 = true;
            break;
        }
        f = a1[f] -1;
        m++;
    }
    if (b1 == true){
        cout << m;
    }
    else if (b1 == false){
        cout << "-1";
    }
}


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

#include <iostream>
#include <string>
using namespace std;
int main(){
    cin>> a;
    int a1[a];
    for (int i = 0; i< a; i++){
        cin>> a1[i];
    }
    f = 0;
    b1 = false;
    m = 0;
    for (int i = 0; i< a; i++){

        if (a1[f] == 2){
            m++;
            b1 = true;
            break;
        }
        f = a1[f] -1;
        m++;
    }
    if (b1 == true){
        cout << m;
    }
    else if (b1 == false){
        cout << "-1";
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:11: error: 'a' was not declared in this scope
    5 |     cin>> a;
      |           ^
a.cc:8:15: error: 'a1' was not declared in this scope
    8 |         cin>> a1[i];
      |               ^~
a.cc:10:5: error: 'f' was not declared in this scope
   10 |     f = 0;
      |     ^
a.cc:11:5: error: 'b1' was not declared in this scope
   11 |     b1 = false;
      |     ^~
a.cc:12:5: error: 'm' was not declared in this scope; did you mean 'tm'?
   12 |     m = 0;
      |     ^
      |     tm
a.cc:15:13: error: 'a1' was not declared in this scope
   15 |         if (a1[f] == 2){
      |             ^~
a.cc:20:13: error: 'a1' was not declared in this scope
   20 |         f = a1[f] -1;
      |             ^~
Language: C++

    cin>> a;
    int a1[a];
    for (int i = 0; i< a; i++){
        cin>> a1[i];
    }
    f = 0;
    b1 = false;
    m = 0;
    for (int i = 0; i< a; i++){
        
        if (a1[f] == 2){
            m++;
            b1 = true;
            break;
        }
        f = a1[f] -1;
        m++;
    }
    if (b1 == true){
        cout << m;
    }
    else if (b1 == false){
        cout << "-1";
    }

Compiler output:
a.cc:1:5: error: 'cin' does not name a type
    1 |     cin>> a;
      |     ^~~
a.cc:2:12: error: 'a' was not declared in this scope
    2 |     int a1[a];
      |            ^
a.cc:3:5: error: expected unqualified-id before 'for'
    3 |     for (int i = 0; i< a; i++){
      |     ^~~
a.cc:3:21: error: 'i' does not name a type
    3 |     for (int i = 0; i< a; i++){
      |                     ^
a.cc:3:27: error: 'i' does not name a type
    3 |     for (int i = 0; i< a; i++){
      |                           ^
a.cc:6:5: error: 'f' does not name a type
    6 |     f = 0;
      |     ^
a.cc:7:5: error: 'b1' does not name a type
    7 |     b1 = false;
      |     ^~
a.cc:8:5: error: 'm' does not name a type
    8 |     m = 0;
      |     ^
a.cc:9:5: error: expected unqualified-id before 'for'
    9 |     for (int i = 0; i< a; i++){
      |     ^~~
a.cc:9:21: error: 'i' does not name a type
    9 |     for (int i = 0; i< a; i++){
      |                     ^
a.cc:9:27: error: 'i' does not name a type
    9 |     for (int i = 0; i< a; i++){
      |                           ^
a.cc:19:5: error: expected unqualified-id before 'if'
   19 |     if (b1 == true){
      |     ^~
a.cc:22:5: error: expected unqualified-id before 'else'
   22 |     else if (b1 == false){
      |     ^~~~
Language: C++

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

int main() {
  int n,pos;
  cin >> n;
  vector<int> data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  for(int count = 0;count < n;count++){
    if(count == 0){
      pos = data.at(0)-1;
    }
    else{
      pos = data.at(pos)-1;
    }
    if(pos == 1){
      cout << count << endl;
      return 0;
    }
    else if(couont == n-1){
      cout << -1 << endl;
      return 0;
    }
    count++;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: 'couont' was not declared in this scope; did you mean 'count'?
   22 |     else if(couont == n-1){
      |             ^~~~~~
      |             count
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: 'j' was not declared in this scope
   19 |   for(j=0;j<n;j++){
      |       ^
Language: C++

#pragma GCC optimize "-O3"
#pragma GCC target ("CMOV")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a,int b){return a*b/gcd(a,b);}
//priority_queue<int, vector<int>, greater<int> > que; //昇順

using namespace std;

const int mod=1e9+7;

int ans=0;



signed main(){
    SPEED;
    int n;
    cin >> n;
    vector<pair<int,bool>> a(n*2);
    rep(i,n)
    {
        cin >> a[i].fi;
        a[i].se = false;
    }
    int ans = 0;
    int now = 0;
    while(a[1].se == false)
    {
        if(a[now].fi == true)
        {
            cout << -1 << endl;
            return 0;
        }
        a[now].se = true;
        ++ans;
        now = a[now].fi - 1;
    }
    cout << ans <<  endl;
    return 0;
}


Compiler output:
cc1plus: error: attribute 'target' argument 'CMOV' is unknown
cc1plus: error: attribute 'target' argument 'CMOV' is unknown
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  vector<int> in(n);
  vector<bool> check(n, false);
  for (int i=0; i<n; i++) {
    cin >> in.at(i);
    in.at(i)--;
  }
  int count = 0;
  int now = 0;
  check.at(0) = true;
  while (true) {
  	now = a.at(now);
    count++;
    if (now == 1) {
      cout << count << endl;
      return 0;
    }
    else if (check.at(now)) {
      cout << -1 << endl;
      return 0;
    }
    check.at(now) = true;
  }
  return 0;
}


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

#include <iostream>
#include<vector>
using namespace std;
int main(void)
{
	// Your code here!
	int a;
	cin >> a;
	vector<int> data(a);
	for (int i = 0; i < a; i++)
	{
		int suuzi;
		cin >> suuzi;
		data[i] = suuzi - 1;
	}
	int box = data[0];
	int cnt = 1;
	while (cnt <= a)
	{
		box = data[box];
		cnt++;
		if (box == 1)
		{
			cout << cnt << endl;
			break;
		}
		if (cnt > a)
		{
			cout << -1 << endl;
			break;
		}

	}

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

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

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

#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define NMAX 100010
using namespace std;
int used[NMAX] = {};
bool tmp = false;
int cnt =0;
void dfs(vector<int> a,int loc){
	used[loc] = true;
	cnt++;
	if(loc == 2){
		tmp = true;
		return;
	}else if(!used[a[loc]]){
		dfs(a,a[loc]);
	}else{
		return;
	}
}

int main(){
	int N;
	cin >> N;
	vector<int> a(N+1);
	rep(i,0,N){
		cin >> a[i+1];
	}
	dfs(a,1);
	

	if(!tmp){
		cout << "-1" << endl;
		return 0;
	}
	cout << cnt-1 << endl;
}


Compiler output:
a.cc:12:6: error: variable or field 'dfs' declared void
   12 | void dfs(vector<int> a,int loc){
      |      ^~~
a.cc:12:10: error: 'vector' was not declared in this scope
   12 | void dfs(vector<int> a,int loc){
      |          ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <utility>
  +++ |+#include <vector>
    3 | #define ll long long int
a.cc:12:17: error: expected primary-expression before 'int'
   12 | void dfs(vector<int> a,int loc){
      |                 ^~~
a.cc:12:24: error: expected primary-expression before 'int'
   12 | void dfs(vector<int> a,int loc){
      |                        ^~~
a.cc: In function 'int main()':
a.cc:27:9: error: 'cin' was not declared in this scope
   27 |         cin >> N;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <utility>
  +++ |+#include <iostream>
    3 | #define ll long long int
a.cc:28:9: error: 'vector' was not declared in this scope
   28 |         vector<int> a(N+1);
      |         ^~~~~~
a.cc:28:9: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:28:16: error: expected primary-expression before 'int'
   28 |         vector<int> a(N+1);
      |                ^~~
a.cc:30:24: error: 'a' was not declared in this scope
   30 |                 cin >> a[i+1];
      |                        ^
a.cc:32:13: error: 'a' was not declared in this scope
   32 |         dfs(a,1);
      |             ^
a.cc:32:9: error: 'dfs' was not declared in this scope
   32 |         dfs(a,1);
      |         ^~~
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout << "-1" << endl;
      |                 ^~~~
a.cc:36:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:9: error: 'cout' was not declared in this scope
   39 |         cout << cnt-1 << endl;
      |         ^~~~
a.cc:39:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'