Language: C++

#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int dat[200000];
int ind[200000];
bool flag[200000];
int vtype[200000];//1: circ1 2: circ2 3: edge
vector<int>circ1[200000];
int circ2[200001];
int flen[200000];
#define SIZE 300000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		scanf("%d", &dat[i]);
		dat[i]--;
		ind[dat[i]]++;
		if (ind[dat[i]] >= 3)
		{
			goto l01;
		}
	}
	for (int i = 0; i < num; i++)
	{
		if (ind[i] == 0)
		{
			int now = i;
			for (;;)
			{
				if (flag[now])
				{
					if (vtype[now] == 0)
					{
						int t = now;
						for (;;)
						{
							vtype[t] = 1;
							circ1[now].push_back(0);
							t = dat[t];
							if (now == t)break;
						}
					}
					else if (vtype[now] == 3)
					{
						goto l01;
					}
					break;
				}
				flag[now] = true;
				now = dat[now];
			}
			now = i;
			int t = 0;
			for (;;)
			{
				if (vtype[now] == 1)
				{
					flen[now] = t;
					break;
				}
				vtype[now] = 3;
				now = dat[now];
				t++;
			}
		}
	}
	for (int i = 0; i < num; i++)
	{
		if (!flag[i])
		{
			int now = i;
			int t = 0;
			for (;;)
			{
				if (flag[now])break;
				flag[now] = true;
				t++;
				now = dat[now];
			}
			circ2[t]++;
		}
	}
	for (int i = 0; i < num; i++)
	{
		int now = i;
		for (int j = 0; j < circ1[i].size(); j++)
		{
			circ1[i][j] = flen[now];
			now = dat[now];
		}
	}
	ll ans = 1;
	for (int i = 0; i < num; i++)
	{
		if (circ1[i].size() >= 1)
		{
			int x = circ1[i].size();
			for (int j = x * 3; j >= 0; j--)
			{
				if (circ1[i][j%x]>2)
				{
					if (circ1[i][(j + x - 1) % x] != 0)
					{
						goto l01;
					}
					circ1[i][(j + x - 1) % x] = circ1[i][j%x] - 1;
					circ1[i][j%x] = 1;
				}
			}
			int r = 1;
			for (int j = 0; j < x; j++)
			{
				if (circ1[i][j] == 1 && circ1[i][(j + 1) % x] == 0)r = r * 2 % mod;
			}
			ans *= r;
			ans %= mod;
		}
	}
	invinit();
	for (int i = 1; i <= num; i++)
	{
		int x = circ2[i];
		ll tim = 1;
		ll now = 1;
		ll r = 0;
		for (int j = 0; j <= x / 2; j++)
		{
			r += com(x, 2 * j)*now%mod*tim%mod;
			now = now*(j * 2 + 1) % mod;
			tim = tim * i % mod;
		}
		ans = ans*r%mod;
	}
	printf("%lld\n", ans);
	if (false)
	{
	l01:;
		printf("0\n");
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:165:9: error: jump to label 'l01'
  165 |         l01:;
      |         ^~~
a.cc:73:54: note:   from here
   73 |                                                 goto l01;
      |                                                      ^~~
a.cc:120:12: note:   crosses initialization of 'll ans'
  120 |         ll ans = 1;
      |            ^~~
a.cc:165:9: error: jump to label 'l01'
  165 |         l01:;
      |         ^~~
a.cc:48:30: note:   from here
   48 |                         goto l01;
      |                              ^~~
a.cc:120:12: note:   crosses initialization of 'll ans'
  120 |         ll ans = 1;
      |            ^~~