Language: C++

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int n,mod=998244353,flag;
int d[101010],book[101010];
long long ans=1;
long long power(long long a,long long b,long long p)
{
	long long num=1%p;
	for(;b;b>>=1)
	{
		if(b&1)
			num=num*a%p;
		a=a*a%p;
	}
	return num%p;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
		book[d[i]]++;
	}
	if(book[0]==0&&n>1)
	{
		printf("0");
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		if(flag&&book[i])
		{
			printf("0");
			return 0;
		}
		if(book[i]==0)
			flag=1;
		ans=(ans%mod*1ll*power(book[i-1],book[i],mod)%mod)%mod;
	}
	printf("%lld",ans%mod);
	return 0;
}#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int n,mod=998244353,flag;
int d[101010],book[101010];
long long ans=1;
long long power(long long a,long long b,long long p)
{
	long long num=1%p;
	for(;b;b>>=1)
	{
		if(b&1)
			num=num*a%p;
		a=a*a%p;
	}
	return num%p;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
		book[d[i]]++;
	}
	if(book[0]==0&&n>1)
	{
		printf("0");
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		if(flag&&book[i])
		{
			printf("0");
			return 0;
		}
		if(book[i]==0)
			flag=1;
		ans=(ans%mod*1ll*power(book[i-1],book[i],mod)%mod)%mod;
	}
	printf("%lld",ans%mod);
	return 0;
}

Compiler output:
a.cc:47:2: error: stray '#' in program
   47 | }#include<cstdio>
      |  ^
a.cc:47:3: error: 'include' does not name a type
   47 | }#include<cstdio>
      |   ^~~~~~~
a.cc:53:5: error: redefinition of 'int n'
   53 | int n,mod=998244353,flag;
      |     ^
a.cc:7:5: note: 'int n' previously declared here
    7 | int n,mod=998244353,flag;
      |     ^
a.cc:53:7: error: redefinition of 'int mod'
   53 | int n,mod=998244353,flag;
      |       ^~~
a.cc:7:7: note: 'int mod' previously defined here
    7 | int n,mod=998244353,flag;
      |       ^~~
a.cc:53:21: error: redefinition of 'int flag'
   53 | int n,mod=998244353,flag;
      |                     ^~~~
a.cc:7:21: note: 'int flag' previously declared here
    7 | int n,mod=998244353,flag;
      |                     ^~~~
a.cc:54:5: error: redefinition of 'int d [101010]'
   54 | int d[101010],book[101010];
      |     ^
a.cc:8:5: note: 'int d [101010]' previously declared here
    8 | int d[101010],book[101010];
      |     ^
a.cc:54:15: error: redefinition of 'int book [101010]'
   54 | int d[101010],book[101010];
      |               ^~~~
a.cc:8:15: note: 'int book [101010]' previously declared here
    8 | int d[101010],book[101010];
      |               ^~~~
a.cc:55:11: error: redefinition of 'long long int ans'
   55 | long long ans=1;
      |           ^~~
a.cc:9:11: note: 'long long int ans' previously defined here
    9 | long long ans=1;
      |           ^~~
a.cc:56:11: error: redefinition of 'long long int power(long long int, long long int, long long int)'
   56 | long long power(long long a,long long b,long long p)
      |           ^~~~~
a.cc:10:11: note: 'long long int power(long long int, long long int, long long int)' previously defined here
   10 | long long power(long long a,long long b,long long p)
      |           ^~~~~
a.cc:67:5: error: redefinition of 'int main()'
   67 | int main()
      |     ^~~~
a.cc:21:5: note: 'int main()' previously defined here
   21 | int main()
      |     ^~~~