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

#include<iostream>
using namespace std;
const int max = 100010;

int main() {
	int N;
	int an[max];
	int count = 1;
	int index = 0;
	bool check = false;

	cin >> N;

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

	for (int i = 0; i < N; i++) {
		if (an[index] == 2) {
			check = true;
			break;
		}
		count++;
		index = an[index] - 1;
	}

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

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:16: error: reference to 'max' is ambiguous
    7 |         int an[max];
      |                ^~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 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/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:3:11: note:                 'const int max'
    3 | const int max = 100010;
      |           ^~~
a.cc:15:24: error: 'an' was not declared in this scope
   15 |                 cin >> an[i];
      |                        ^~
a.cc:19:21: error: 'an' was not declared in this scope
   19 |                 if (an[index] == 2) {
      |                     ^~
a.cc:24:25: error: 'an' was not declared in this scope
   24 |                 index = an[index] - 1;
      |                         ^~
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

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


Compiler output:
a.cc: In function 'int main()':
a.cc:42:14: error: 'n' was not declared in this scope; did you mean 'yn'?
   42 |         cin>>n;
      |              ^
      |              yn
Language: C++

if __name__ == "__main__":
    N = int(input())
    A = []
    for x in range(N):
        y = int(input())
        y -= 1
        A.append(y)
    pos = 0
    cnt = 0
    visited = set()
    while (cnt <= N + 1):
        visited.add(pos)
        if (pos == 1):
            print (cnt)
            exit()
        pos = A[pos]
        cnt += 1
        if pos in visited:
            break

    print (-1)


Compiler output:
a.cc:1:1: error: expected unqualified-id before 'if'
    1 | if __name__ == "__main__":
      | ^~
Language: C++

//abc065_b Trained?


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

namespace
{
bool bFlag[ 100010 ];
int a[ 100010 ];
}

int main()
{
int i;
int N;
int iCnt;

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

	iCnt = 1;
	i = 1;
	while( ! bFlag[ i ] )
	{
		bFlag[ i ] = true;
		if( i == 2 )
		{
			cout << iCnt << endl;

			return 0;
		}

		iCnt++;
		i = a[ i ]
	}

	cout << - 1 << endl;

	return 0;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:38:27: error: expected ';' before '}' token
   38 |                 i = a[ i ]
      |                           ^
      |                           ;
   39 |         }
      |         ~
Language: C++

button = $stdin.read.split("\n")
button.map! do |element|
	element.to_i
end
button.shift()
current = 0
cnt = 0
while true
	if current == 1
		print("#{cnt}\n")
		break
	elsif cnt >= button.size
		print("-1\n")
		break
	end
	cnt += 1
	current = button[current-1]
end



Compiler output:
a.cc:1:1: error: 'button' does not name a type
    1 | button = $stdin.read.split("\n")
      | ^~~~~~
Language: C

#include <stdio.h>
#define MAX 10000
int main(void){
  int N, c, now, a[MAX];
  scanf("%d", &N);
  
  for(i=0;i<N;i++){
    scanf("%d", &(a[i]));
    a[i]--;
  }
  
  c = 0;
  now = 0;
  while(1){
    if(now == 1){
      printf("%d\n", c);
      break;
    }
    if(c >= N){
      printf("-1\n");
      break;
    }
    c++;
    now = a[now];
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:7: error: 'i' undeclared (first use in this function)
    7 |   for(i=0;i<N;i++){
      |       ^
main.c:7:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

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

    int index=0;
    int i=0;
    while(i<=n){
        if(a[index]==2){
            cout<<index+1<<endl;
            break;
        }
        index=a[index]-1;
        i++;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin>>n;
      |     ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <algorithm>
  +++ |+#include <iostream>
    4 | 
a.cc:19:13: error: 'cout' was not declared in this scope
   19 |             cout<<index+1<<endl;
      |             ^~~~
a.cc:19:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:28: error: 'endl' was not declared in this scope
   19 |             cout<<index+1<<endl;
      |                            ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include <algorithm>
  +++ |+#include <ostream>
    4 |
Language: C++

int main(void) {
   int a;
   scanf("%d", &a);
   int A[a];
   for (int i = 0; i < a; i++ ) {
      scanf("%d", &A[i]);
   }
   int light;
   int count = 1;
   for (light = A[0]; light != 2; count++) {
      if (count >= a ) {
         printf("-1");
         break;
      }
      light = A[light-1];
   }
   if (light == 2 ) {
      printf("%d\n", count);
   }
   return 0;
   



}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:4: error: 'scanf' was not declared in this scope
    3 |    scanf("%d", &a);
      |    ^~~~~
a.cc:12:10: error: 'printf' was not declared in this scope
   12 |          printf("-1");
      |          ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | int main(void) {
a.cc:18:7: error: 'printf' was not declared in this scope
   18 |       printf("%d\n", count);
      |       ^~~~~~
a.cc:18:7: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#include <iostream>

using namespace std;
#define Nmax 100000
int main() {
	int N;
	int a;
	int start;
	int Nnum[Nmax];
	scanf("%d", &N);
	for (int i = 1; i < N + 1; i++) {
		scanf("%d", &a);
		Nnum[i] = a;
	}
	int next = 1;
	int count = 0;
	while (count<N) {
		next = Nnum[next];
		count++;
		if (next == 2)
			break;
	}
	if (next == 2)
		printf("%d\n", count);
	else
		printf("%d\n", -1);


Compiler output:
a.cc: In function 'int main()':
a.cc:26:36: error: expected '}' at end of input
   26 |                 printf("%d\n", -1);
      |                                    ^
a.cc:5:12: note: to match this '{'
    5 | int main() {
      |            ^
Language: C++

#include <iostream>
using namespace std;
int main()
{
int n, i, j, k, x, y, z, c=0;
cin. tie(0);
for (i = 1; i <= n; i++) cin>> A[i];
x = 1;
c = 0;
mark[1] = 1; 
while (x != 2) {
	  c++;
	  x=A[x];
	  if (mark[x]) break;
	  mark[x] = 1;
}
if(x == 2) cout << c << endl;
else cout << -1 << endl;  
return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:7:32: error: 'A' was not declared in this scope
    7 | for (i = 1; i <= n; i++) cin>> A[i];
      |                                ^
a.cc:10:1: error: 'mark' was not declared in this scope
   10 | mark[1] = 1;
      | ^~~~
a.cc:13:13: error: 'A' was not declared in this scope
   13 |           x=A[x];
      |             ^
Language: C++

#include <iostream>
using namespace std;
int main()
{
	int n,i,j,k,x,y,z,c=0;
	cin>>n;
	for(i=1;i<=n;++i)cin>>A[i];
	x=1;
	c=0;
	mark[1]=1;
	while(x!=2)
{
	c++;
	x=A[x];if(mark[x])break;
	mark[x]=1;
}
    if(x==2)cout<<e<<endl;
    else cout<<-1<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:31: error: 'A' was not declared in this scope
    7 |         for(i=1;i<=n;++i)cin>>A[i];
      |                               ^
a.cc:10:9: error: 'mark' was not declared in this scope
   10 |         mark[1]=1;
      |         ^~~~
a.cc:14:11: error: 'A' was not declared in this scope
   14 |         x=A[x];if(mark[x])break;
      |           ^
a.cc:17:19: error: 'e' was not declared in this scope
   17 |     if(x==2)cout<<e<<endl;
      |                   ^
Language: C++

#include<iostream>
using namespace std;
int mark[100001],A[100001]
int main()
{
ios_base::sync_with_stdio(false)
cin.tie(0);
int n,i,j,k,x,y,z,c=0;
cin>>n;
for(i=1;i<=n;++1)cin>>A[i]
x=1;
c=0;
mark[1]=1;
while(x!=2){
c++;
x=A[x];
if(mark[x])break;
mark[x]=1;
}
if(x==2)cout<<c<<end;
else cout<<-1<<endl;
return 0;
}


Compiler output:
a.cc:4:1: error: expected initializer before 'int'
    4 | int main()
      | ^~~
Language: C++

#include <iostream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cctype>
#include <string.h>
#include <ctime>  
#include <windows.h>
using namespace std;

int mark[100001],a[100001];

int main()
{
	int x,c,n,i,j,k,y,z;
	cin>>n;
	for (i=1;i<=n;i++) cin>>a[i];
	
	x=1;
	c=0;
	while (x!=2)
	{
		c++;
		x=a[x];
		if (mark[x]) break;	
		mark[x]=1;
	}
	
	if (x==2) 
		cout<<c<<endl;
	else 
		cout<<"-1"<<endl;
	
	return 0;
}


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

#include <iostream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cctype>
#include <string.h>
#include <ctime>  
#include <conio.h>  
#include <windows.h>
using namespace std;

int mark[100001],a[100001];

int main()
{
	int x,c,n,i,j,k,y,z;
	cin>>n;
	for (i=1;i<=n;i++) cin>>a[i];
	
	x=1;
	c=0;
	while (x!=2)
	{
		c++;
		x=a[x];
		if (mark[x]) break;	
		mark[x]=1;
	}
	
	if (x==2) 
		cout<<c<<endl;
	else 
		cout<<"-1"<<endl;
	
	return 0;
}


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

#include <iostream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cctype>
#include <string.h>
#include <ctime>  
#include <conio.h>  
#include <windows.h>  
using namespace std;

int a[100005],b[100005];

int main()
{
	int n,s=0;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for (int i=1;i<=100005;)
	{
		b[i]=1;
		i=a[i];
		s++;
		if (i==2)
		{
			cout<<s<<endl;
			return 0;
		}
		else if (b[i]==1)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	
	return 0;
 } 


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

#include<iostream>
#include<Cstring>
using namespace std;
int main(){
	int N;
	int j=0;
	int b=1; 
	int c[100000];
	int d=0;
	int a[100000];
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>a[i];
	}
	while(b!=2){
		c[j]=b;
		for(int k=0;k<=j;k++){
			if(c[k]==b) d=1;
		}
		if(d==1) break;
		else {
		j++;
		b=a[b];
		}
	} 
	if(d==0) cout<<j<<endl;
	else cout<<"-1"<<endl;
}

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

// 170613_test.cpp : メイン プロジェクト ファイルです。

#include "stdio.h"
#include "stdafx.h"

using namespace System;

int main()
{
    int n;
    scanf("%d", &n);

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

	int f = 0;
	int tmp = 1;
	for (int j = 0; j < n; j++) {
		tmp = a[tmp - 1];

		if (tmp = 2) {
			printf(j);
			break;
			f = 1;
		}
	}
	if (f == 0) {
		printf("-1");
	}
    return 0;
}

Compiler output:
a.cc:4:10: fatal error: stdafx.h: No such file or directory
    4 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: Java

package atcoder;

import java.util.Scanner;
import java.io.PrintWriter;

public class TaskB {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int[]arr = new int[n+1];
        for(int i = 1; i <= n; ++i) {
            arr[i] = in.nextInt();
        }

        boolean[] vis = new boolean[n+1];
        int cur = 1;
        int ans = 0;
        while(cur != 2 && !vis[cur]) {
            vis[cur] = true;
            cur = arr[cur];
            ++ans;
        }

        out.println(cur != 2 ? -1 : ans);

    }
}


Compiler output:
Main.java:6: error: class TaskB is public, should be declared in a file named TaskB.java
public class TaskB {
       ^
1 error
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
using namespace std;
int vals[100001];
int vis[100001];
int main() {
	int N;
	scanf("%d",&N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &vals[i]);
	}
	memset(vis, 0, sizeof vis);
	bool good = false;
	int counter = 0;
	int cur = 1;
	while (true) {
		if (vis[cur]) {
			break;
		}
		vis[cur] = 1;
		cur = vals[cur];
		counter++;
		if (cur == 2) {
			good = true;
			break;
		}
	}
	if (good) {
		printf("%d", counter);
	}
	else {
		printf("-1");
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'memset' was not declared in this scope
   13 |         memset(vis, 0, sizeof vis);
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cstdio>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

#include<iostream>
using namespace std;
int main(){
	int n,b=1,count=0,d;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	while(a[b-1]!=0 && a[b-1]!=2){
		d=b;
		b=a[b-1];
		a[d-1]=0;
		count=count+1;
	}
	if(a[b-1]==2){
		cout<<count+1<<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:32: error: expected primary-expression before '<' token
   17 |                 cout<<count+1<<<endl;
      |                                ^
Language: C++

#include<iostream>
using namespace std;
int main(){
	int n,b=1,countnt=0,d;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	while(a[b-1]!=0 && a[b-1]!=2){
		d=b;
		b=a[b-1];
		a[d-1]=0;
		count=count+1;
	}
	if(a[b-1]==2){
		cout<<count+1<<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 'count' was not declared in this scope; did you mean 'countnt'?
   14 |                 count=count+1;
      |                 ^~~~~
      |                 countnt
a.cc:17:23: error: 'count' was not declared in this scope; did you mean 'countnt'?
   17 |                 cout<<count+1<<<endl;
      |                       ^~~~~
      |                       countnt
a.cc:17:32: error: expected primary-expression before '<' token
   17 |                 cout<<count+1<<<endl;
      |                                ^
Language: C++

#include<iostream>
using namespace std;
int main(){
	int n,b=1,c=0,d;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	while(a[b-1]!=0 && a[b-1]!=2){
		d=b;
		b=a[b-1];
		a[d-1]=0;
		count=count+1;
	}
	if(a[b-1]==2){
		cout<<count+1<<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: 'count' was not declared in this scope
   14 |                 count=count+1;
      |                 ^~~~~
a.cc:17:23: error: 'count' was not declared in this scope
   17 |                 cout<<count+1<<<endl;
      |                       ^~~~~
a.cc:17:32: error: expected primary-expression before '<' token
   17 |                 cout<<count+1<<<endl;
      |                                ^
Language: C++

#include<iostream>
using namespace std;
int main(){
	int n,b=1,c=0,d;
	cin>>n;
	int a[n];
	for(int i=0;i<nli++){
		cin>>a[i];
	}
	while(a[b-1]!=0 && a[b-1]!=2){
		d=b;
		b=a[b-1];
		a[d-1]=0;
		count=count+1;
	}
	if(a[b-1]==2){
		cout<<count+1<<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:23: error: 'nli' was not declared in this scope
    7 |         for(int i=0;i<nli++){
      |                       ^~~
a.cc:7:28: error: expected ';' before ')' token
    7 |         for(int i=0;i<nli++){
      |                            ^
      |                            ;
a.cc:14:17: error: 'count' was not declared in this scope
   14 |                 count=count+1;
      |                 ^~~~~
a.cc:17:23: error: 'count' was not declared in this scope
   17 |                 cout<<count+1<<<endl;
      |                       ^~~~~
a.cc:17:32: error: expected primary-expression before '<' token
   17 |                 cout<<count+1<<<endl;
      |                                ^
Language: C++

#include <iostream>

using namespace std;

int main() {
	int n,k=0,i;
	bool m1 = true;4

	cin >> n;
	int *a = new int[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	i = 0;
	while (m1) {
		k++;
		if (a[i] == 2) { m1 = false;}
		else { i = a[i];
			if (k > n) { m1 = false; k = -1; }
		}
	}
	cout << k;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:25: error: expected ';' before 'cin'
    7 |         bool m1 = true;4
      |                         ^
      |                         ;
    8 | 
    9 |         cin >> n;
      |         ~~~
Language: C++

#include <iostream>
using namespace std;
int a[123456];
int main(){
  int n;cin>>n;
for(int i=0;i<n;++i){cin>>a[i];a[i]--;}
int inf = 200000;
int mi=inf;
int pos=0;
for (int i=0;i<inf;++i){
if(pos==1) mi = min(mi, i);
pos=a[pos];
}
cout<<(mi==inf?-1:mi) << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:14:31: error: expected '}' at end of input
   14 | cout<<(mi==inf?-1:mi) << endl;
      |                               ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

N=int(raw_input())
a=[-1]
for _ in range(N):
    a.append(int(raw_input()))
 
 
i=1
c=0
while(1):
    if i==2:
        print c
        break
    elif c>=N:
        print -1
        break
    c+=1
    i=a[i]
            

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

from collections import defaultdict,deque
dic=defaultdict(list)
n=int(input())
for i in range(1,n+1):
    num=int(input())
    dic[num].append(i)
que=deque()
que.append(2)
co=0
while que:
    key=que.popleft()
    co+=1
    if co>n:
        print(str(-1))
        break
    if key==2:
        print(n)
        break
    for i in dic[key]:
        que.append(i)
    else:
        print(-1)
        break


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import defaultdict,deque
      | ^~~~
Language: Java

import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.valueOf(sc.nextInt());
		int a[] = new int[N];
		int i;

		for(i=0; i<N; i++){
			a[i] = sc.nextInt();
		}

		int judge=0;
		i = 0;
		int count=0;
		while(judge != 2){
			judge = a[i];
			count++;
			i = judge-1;
			if(count > N) break;
		}
		if(count<N){
			System.out.println(count);
		}
		else{
			System.out.println(-1);
		}
	}
}

Compiler output:
Main.java:3: error: class B is public, should be declared in a file named B.java
public class B {
       ^
1 error
Language: Java

import java.io.IOException;
import java.util.Scanner;

public class PB {
	public static int searchId(int n, int[] a, int id) throws IOException {
		for (int i = 0; i < n; i++) {
			if (a[i] == id)
				return i + 1;
		}
		return -1;
	}

	public static void solve() throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int cnt = 1;
		int id = searchId(n, a, 2);
		if (id == 1) {
			System.out.println(cnt);
		} else if (id == -1) {
			System.out.println(-1);
		} else {
			for (int i = 0; i < n; i++) {
				cnt++;
				id = searchId(n, a, id);
				if (id == 1) {
					System.out.println(cnt);
					break;
				} else if (id == -1) {
					System.out.println(-1);
					break;
				}
			}
		}
		if (id != 1 && id != -1 && cnt == n + 1)
			System.out.println(-1);

		sc.close();
	}

	public static void main(String[] args) {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


Compiler output:
Main.java:4: error: class PB is public, should be declared in a file named PB.java
public class PB {
       ^
1 error
Language: C++

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n, ans;
int a[100005];
int flag;
int main()
{
	flag = 0;
	ans = 0;
	memset(a, 0, sizeof(a));
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	int p = a[1];
	a[1] = 0;
	while(true)
	{
		if(ans > 1000000 || a[o] == 0) {flag = 1; break;}
		if(p == 2) break;
		ans++;
		int o = p;
		p = a[p];
		a[o] = 0;
	}
	if(flag == 1) printf("-1\n");
	else printf("%d\n", ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:39: error: 'o' was not declared in this scope
   24 |                 if(ans > 1000000 || a[o] == 0) {flag = 1; break;}
      |                                       ^
Language: C++

#include <iostream>
#include <vector>
#include <alglorithm>

using namespace std;

int main(){
  long n;
  vector<long> a[100000], res;
  
  cin >> n;
  for (long i = 0;i<n;i++) {
    long ai;
    cin >> ai;
    a[(ai-1)].push_back(i);
  }
  res = a[1];
  
  if (find(res.begin(), res.end(), (long)0)!=res.end()) {
    cout << 1 << endl;
    return 0;
  }
  res = a[1];
  for (long i=0;i<=n;i++) {
    vector<long> tmp;
    for (auto it=res.begin();it!=res.end();it++) {
      tmp.insert(tmp.end(), a[(*it)].begin(), a[(*it)].end());
    }
    res = tmp;
    if (find(tmp.begin(), tmp.end(), (long)0)!=tmp.end()) {
      cout << (i+2) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 1;
}




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

#include <iostream>
#include <vector>

using namespace std;

int main(){
  long n;
  vector<long> a[100000], res;
  
  cin >> n;
  for (long i = 0;i<n;i++) {
    long ai;
    cin >> ai;
    a[(ai-1)].push_back(i);
  }
  res = a[1];
  
  if (find(res.begin(), res.end(), (long)0)!=res.end()) {
    cout << 1 << endl;
    return 0;
  }
  res = a[1];
  for (long i=0;i<=n;i++) {
    vector<long> tmp;
    for (auto it=res.begin();it!=res.end();it++) {
      tmp.insert(tmp.end(), a[(*it)].begin(), a[(*it)].end());
    }
    res = tmp;
    if (find(tmp.begin(), tmp.end(), (long)0)!=tmp.end()) {
      cout << (i+2) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 1;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:18:11: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, long int)'
   18 |   if (find(res.begin(), res.end(), (long)0)!=res.end()) {
      |       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:18:11: note:   '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   18 |   if (find(res.begin(), res.end(), (long)0)!=res.end()) {
      |       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:13: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, long int)'
   29 |     if (find(tmp.begin(), tmp.end(), (long)0)!=tmp.end()) {
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:29:13: note:   '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   29 |     if (find(tmp.begin(), tmp.end(), (long)0)!=tmp.end()) {
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

int ans, n, x;

vector < int > g[N5];

dfs (int v, int h)
{
    ++ans;
//    cout << v << " ";
    if (v == 2)
    {
        cout << ans - 1;
        exit(0);
    }
    if (h == 1 && v == 1)
    {
        cout << -1;
        exit(0);
    }
    fora (to, g[v])
        dfs(to, 1);
}

int main()
{
    cin >> n;
    forn (i, 1, n)
    {
        cin >> x;
        g[i].pb(x);
    }
    dfs(1, -1);
    cout << ans - 1;
}


Compiler output:
a.cc:29:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   29 | dfs (int v, int h)
      | ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
Language: C++


言 2017/6/24 21:10:57
#include <stdio.h>
#define MAX 100000
int main()
{
	int n,num=0;
	int a[MAX];
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	  i=1;
	  while(1)
	  {
  		num++;
  		if(a[i]==2)
  		{
		  	printf("%d",num);
		  	break;
		  }
		  i=a[i];
		  if(num>n)
		  {
  			printf("-1");
  			break;
  		}
  	}
	
	

}

Compiler output:
a.cc:2:1: error: '\U00008a00' does not name a type
    2 | 言 2017/6/24 21:10:57
      | ^~
a.cc: In function 'int main()':
a.cc:10:9: error: 'scanf' was not declared in this scope
   10 |         scanf("%d",&n);
      |         ^~~~~
a.cc:19:25: error: 'printf' was not declared in this scope
   19 |                         printf("%d",num);
      |                         ^~~~~~
a.cc:4:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    3 | #include <stdio.h>
  +++ |+#include <cstdio>
    4 | #define MAX 100000
a.cc:25:25: error: 'printf' was not declared in this scope
   25 |                         printf("-1");
      |                         ^~~~~~
a.cc:25:25: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

int ans, n, x;

vector < int > g[N5];

dfs (int v, int h = -1)
{
    ++ans;
//    cout << v << " ";
    if (v == 2)
    {
        cout << ans - 1;
        exit(0);
    }
    if (h == 1 && v == 1)
    {
        cout << -1;
        exit(0);
    }
    fora (to, g[v])
        dfs(to, 1);
}

int main()
{
    cin >> n;
    forn (i, 1, n)
    {
        cin >> x;
        g[i].pb(x);
    }
    dfs(1);
    cout << ans - 1;
}


Compiler output:
a.cc:29:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   29 | dfs (int v, int h = -1)
      | ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int main(){
  long n;
  vector<long> a[100000], res;
  
  cin >> n;
  for (long i = 0;i<n;i++) {
    long ai;
    cin >> ai;
    a[(ai-1)].push_back(i);
  }
  // res.insert(res.end(), a[2].begin(), a[2].end());
  res = a[1];
  
  if (find(res.begin(), res.end(), 0)!=res.end()) {
    cout << 1 << endl;
    return 0;
  }
  res = a[1];
  for (long i=0;i<=n;i++) {
    vector<long> tmp;
    for (auto it=res.begin();it!=res.end();it++) {
      tmp.insert(tmp.end(), a[(*it)].begin(), a[(*it)].end());
    }
    res = tmp;
    if (find(tmp.begin(), tmp.end(), 0)!=tmp.end()) {
      cout << (i+2) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 1;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:19:11: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, int)'
   19 |   if (find(res.begin(), res.end(), 0)!=res.end()) {
      |       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:19:11: note:   '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   19 |   if (find(res.begin(), res.end(), 0)!=res.end()) {
      |       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:13: error: no matching function for call to 'find(std::vector<long int>::iterator, std::vector<long int>::iterator, int)'
   30 |     if (find(tmp.begin(), tmp.end(), 0)!=tmp.end()) {
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:30:13: note:   '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   30 |     if (find(tmp.begin(), tmp.end(), 0)!=tmp.end()) {
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

int ans, n, x;

vector < int > g[N5];

dfs (int v, int h = -1)
{
    ++ans;
//    cout << v << " ";
    if (v == 2)
    {
        cout << ans;
        exit(0);
    }
    if (h == 1 && v == 1)
    {
        cout << -1;
        exit(0);
    }
    fora (to, g[v])
        dfs(to, 1);
}

int main()
{
    cin >> n;
    forn (i, 1, n)
    {
        cin >> x;
        g[x].pb(i);
    }
    dfs(1);
    cout << ans;
}


Compiler output:
a.cc:29:1: error: ISO C++ forbids declaration of 'dfs' with no type [-fpermissive]
   29 | dfs (int v, int h = -1)
      | ^~~
a.cc: In function 'int dfs(int, int)':
a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type]
   45 | }
      | ^
Language: C++

#include<stdio.h>
#define MAX 100000
int main()
{
  int n,num=0;
  int a[MAX];
  int i ;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  scanf("%d",&a[i]);
  i=1;
  while(1)
  {
  	num++;
  	if(a[i]==2)
  	{
	  	printf("%d\n",num);
	  	break;
  
  i=a[i];
  if(num>n)
  {
  	printf("-1\n");
  	break;
  }}
  return 0;
} 

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

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class B {

	public static void Main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] buttons = new int[n];
		for(int i=0;i<n;i++){
			buttons[i] = sc.nextInt();
		}
		sc.close();
		
		int glowinBtn = 1;
		Set<Integer> pshdBtn = new HashSet<Integer>();
		do{
			pshdBtn.add(glowinBtn);
			glowinBtn = buttons[glowinBtn-1];
			
		}while(!(glowinBtn==2 || pshdBtn.contains(glowinBtn)));
		
		int result = -1;
		
		if(glowinBtn==2){
			result = pshdBtn.size();
		}
		
		System.out.print(result);
		
		return;
	}
}

Compiler output:
Main.java:5: error: class B is public, should be declared in a file named B.java
public class B {
       ^
1 error
Language: C++

#include <iostream>
using namespace std;

int z;
int n;
int x[100005];
int now ;
int counter = 0;
int a;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:32:25: error: 'couter' was not declared in this scope; did you mean 'counter'?
   32 |                         couter --;
      |                         ^~~~~~
      |                         counter
Language: Java

public class Main{
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        boolean[] b = new boolean[n];
        b[0] = true;
        for (int i = 1; i < n; i++) b[i] = false;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (b[1] == true) break;
            if (i == n - 1) {
                count = -1;
                break;
            }    
            for (int j = 0; j < n; j++) {
                if (b[j] == true) {
                   b[j] = false;
                   b[array[j] - 1] = true;
                   count++;
                }
            }
        }
        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: Java

import java.util.Scanner;

public class Maiin {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < num.length; i++) {
			num[i] = scanner.nextInt();
		}
		boolean[] check = new boolean[n];
		int i = 0;
		int count = 0;
		while (!check[i]) {
			//System.out.println(i);
			count++;
			check[i] = true;
			i = num[i] - 1;
			if (i == 1) {
				System.out.println(count);
				System.exit(0);
			}
		}
		System.out.println("-1");
		scanner.close();
	}
}


Compiler output:
Main.java:3: error: class Maiin is public, should be declared in a file named Maiin.java
public class Maiin {
       ^
1 error
Language: C++

/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair
#define long long int

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7, MAXN = 1e5 + 10;

int n, a[MAXN], u[MAXN], d[MAXN];

void dfs(int v){
    if (u[v] == 1)
        return;
    d[a[v]] = d[v] + 1;
    u[v] = 1;
    dfs(a[v]);
}

main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    dfs(1);
    cout << (u[2] == 0 ? -1 : d[2]);
    return 0;
}


Compiler output:
a.cc:12:19: error: two or more data types in declaration of 'll'
   12 | #define long long int
      |                   ^~~
a.cc:16:9: note: in expansion of macro 'long'
   16 | typedef long long ll;
      |         ^~~~
a.cc:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main(){
      | ^~~~
Language: C++

#define N 100000

int n;
int a[N];
int color[N + 1];

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

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

#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


// 階乗mod
ll fmod(ll n){
    ll ans = 1;
    for(ll i = 1; i <= n; i++){
        ans *= i;
        ans %= MOD;
    }

    return ans;
}

int main(){
    ll N, M;
    cin >> N >> M;

    ll
    if(N == M){
        cout << (2 * fmod(N) % MOD) * fmod(M) % MOD << endl;
    }else if(abs(N - M) == 1){
        if(N < M){
            swap(N, M);
        }
        cout << fmod(N) * fmod(M) % MOD << endl;
    }else{
        cout << 0 << endl;
    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:5: error: expected unqualified-id before 'if'
   41 |     if(N == M){
      |     ^~
a.cc:43:6: error: 'else' without a previous 'if'
   43 |     }else if(abs(N - M) == 1){
      |      ^~~~
Language: C

#include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,ans,mod,i,modp[200001];
  scanf("%lld %lld",&a,&b);
  mod=pow(10,9)+7;
  modp[0]=1
  for(i=1;i<200001;++i)
  {
  modp[i]=(modp[i-1]*i)%mod;
  }
  ans=(modp[a]*modp[b])%mod;
  if(abs(a-b)>1) printf("0");
  else printf("%lld",ans);
return 0;}

Compiler output:
main.c: In function 'main':
main.c:8:12: error: expected ';' before 'for'
    8 |   modp[0]=1
      |            ^
      |            ;
    9 |   for(i=1;i<200001;++i)
      |   ~~~       
main.c:14:6: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   14 |   if(abs(a-b)>1) printf("0");
      |      ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | int main()
main.c:14:11: warning: 'abs' argument 1 type is 'long long int' where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
   14 |   if(abs(a-b)>1) printf("0");
      |          ~^~
<built-in>: note: built-in 'abs' declared here
Language: C++

#include<bits/stdc++.h>
#define D 1000000007
using namespace std;
using ull = long long;

}

int main(){
    ull n, m; cin >> n >> m;
    ull ans =0;
    ull n_func=1, m_func=1;
    if(n-m > 1 || m-n > 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=n; i>=1; i--){
        n_func = n_func*i;
        n_func = n_func%D;
    }
    for(int i=m; i>=1; i--){
        m_func = m_func*i;
        m_func = m_func%D;
    }
    ans = n_func * m_func;
    if(n==m) ans = ans*2;
    ans = ans%D;

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

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

#include<bits/stdc++.h>
#define D 1000000007
using namespace std;
using ull = unsigned long long;

int main(){
    ull n, m; cin >> n >> m;
    ull ans =0;
    ull n_func=1, m_func=1;
    if(abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=n; i>=1; i--){
        n_func = n_func*i;
        n_func = n_func%D;
    }
    for(int i=m; i>=1; i--){
        m_func = m_func*i;
        m_func = m_func%D;
    }
    ans = n_func * m_func;
    if(n==m) ans = ans*2;
    ans = ans%D;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:11: error: call of overloaded 'abs(ull)' is ambiguous
   10 |     if(abs(n-m) > 1){
      |        ~~~^~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Language: C++

/*
  Contest 065
  C - Reconciled?
  Rakesh Kumar --> 01/09/2020
 */

#include <bits/stdc++.h>

using ll = long long int;

ll f (ll n) {
    ll r = 1;
    for (ull i = 2; i <= n; ++i)
        r = (r * i) % static_cast<ll>((1e9 + 7));
    return r;
}

/*
  combinations maths questions.
  for example
  D --> dog, M --> Monkey
  if abs(D - M) == 0
  let's D = M = 2
  can be 2 combinations where DMDM or MDMD therefore (D! * M!) * 2
  if abs(D - M) = 1
  DMD, MDM so D! * M!
  else abs(D - M) > 1
  0, because dog and monkey can't stand each other
 */

const ll M = (1e9 + 7);

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    ll n = 0, m = 0;
    std::cin >> n >> m;
    ll result = 1;
    if (std::abs(n - m) <= 1) {
        /*
        result = f(n);
        result *= f(m);
        */
        for (int i = 2; i <= n; ++i)
            result = result * i % M;
        for (int i = 1; i <= m; ++i)
            result = result * i % M;
    }
    if (n == m)
        result = result * 2 % M;
    std::cout << result << std::endl;

    return 0;
}


Compiler output:
a.cc: In function 'll f(ll)':
a.cc:13:10: error: 'ull' was not declared in this scope; did you mean 'll'?
   13 |     for (ull i = 2; i <= n; ++i)
      |          ^~~
      |          ll
a.cc:13:21: error: 'i' was not declared in this scope
   13 |     for (ull i = 2; i <= n; ++i)
      |                     ^