Language: C++

#include<iostream>
#include<vector>
#include<cstdlib>
#include<gmpxx.h>

mpz_class fact(int);

using namespace std;

int main(){
	int n,m;
	int c = 100000000+7;
	cin >> n >> m;
	if(n==m){
		cout << (fact(n)*2*2)%c << endl;
	}
	else if(abs(n-m)==1){
		cout << (fact(n)*fact(m))%c << endl;
	}
	else {
		cout << 0 << endl;
	}
}

mpz_class fact(int n){
	if(n==0)return 1;
	else return n*fact(n-1);
}

/*

#include<iostream>
#include<vector>
#include<cstdlib>
#include<gmpxx.h>

mpz_class fact(int);

using namespace std;

int main(){
	int cnt = 10000;

	cout << fact(cnt)%(1000000000+7) << endl;


}

mpz_class fact(int n){
	if(n==0)return 1;
	else return n*fact(n-1);
}

*/






Compiler output:
/usr/bin/ld: /tmp/ccU5bANH.o: in function `__gmp_binary_multiplies::eval(__mpz_struct*, __mpz_struct const*, __mpz_struct const*)':
a.cc:(.text._ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_S3_[_ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_S3_]+0x27): undefined reference to `__gmpz_mul'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `__gmp_binary_multiplies::eval(__mpz_struct*, __mpz_struct const*, long)':
a.cc:(.text._ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_l[_ZN23__gmp_binary_multiplies4evalEP12__mpz_structPKS0_l]+0x27): undefined reference to `__gmpz_mul_si'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `__gmp_binary_modulus::eval(__mpz_struct*, __mpz_struct const*, long)':
a.cc:(.text._ZN20__gmp_binary_modulus4evalEP12__mpz_structPKS0_l[_ZN20__gmp_binary_modulus4evalEP12__mpz_structPKS0_l]+0x32): undefined reference to `__gmpz_tdiv_r_ui'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::init_si(long)':
a.cc:(.text._ZN10__gmp_exprIA1_12__mpz_structS1_E7init_siEl[_ZN10__gmp_exprIA1_12__mpz_structS1_E7init_siEl]+0x1f): undefined reference to `__gmpz_init_set_si'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::~__gmp_expr()':
a.cc:(.text._ZN10__gmp_exprIA1_12__mpz_structS1_ED2Ev[_ZN10__gmp_exprIA1_12__mpz_structS1_ED5Ev]+0x14): undefined reference to `__gmpz_clear'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `std::ostream& operator<< <__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, long, __gmp_binary_multiplies> >, long, __gmp_binary_multiplies> >, long, __gmp_binary_modulus> >(std::ostream&, __gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, long, __gmp_binary_multiplies> >, long, __gmp_binary_multiplies> >, long, __gmp_binary_modulus> > const&)':
a.cc:(.text._ZlsIA1_12__mpz_struct17__gmp_binary_exprI10__gmp_exprIS1_S2_IS3_IS1_S2_IS3_IS1_S1_El23__gmp_binary_multipliesEElS5_EEl20__gmp_binary_modulusEERSoSC_RKS3_IT_T0_E[_ZlsIA1_12__mpz_struct17__gmp_binary_exprI10__gmp_exprIS1_S2_IS3_IS1_S2_IS3_IS1_S1_El23__gmp_binary_multipliesEElS5_EEl20__gmp_binary_modulusEERSoSC_RKS3_IT_T0_E]+0x46): undefined reference to `operator<<(std::ostream&, __mpz_struct const*)'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `std::ostream& operator<< <__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_binary_multiplies> >, long, __gmp_binary_modulus> >(std::ostream&, __gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_binary_multiplies> >, long, __gmp_binary_modulus> > const&)':
a.cc:(.text._ZlsIA1_12__mpz_struct17__gmp_binary_exprI10__gmp_exprIS1_S2_IS3_IS1_S1_ES4_23__gmp_binary_multipliesEEl20__gmp_binary_modulusEERSoSA_RKS3_IT_T0_E[_ZlsIA1_12__mpz_struct17__gmp_binary_exprI10__gmp_exprIS1_S2_IS3_IS1_S1_ES4_23__gmp_binary_multipliesEEl20__gmp_binary_modulusEERSoSA_RKS3_IT_T0_E]+0x46): undefined reference to `operator<<(std::ostream&, __mpz_struct const*)'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr<__gmp_binary_expr<long, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_binary_multiplies> >(__gmp_expr<__mpz_struct [1], __gmp_binary_expr<long, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_binary_multiplies> > const&)':
a.cc:(.text._ZN10__gmp_exprIA1_12__mpz_structS1_EC2I17__gmp_binary_exprIlS2_23__gmp_binary_multipliesEEERKS_IS1_T_E[_ZN10__gmp_exprIA1_12__mpz_structS1_EC5I17__gmp_binary_exprIlS2_23__gmp_binary_multipliesEEERKS_IS1_T_E]+0x18): undefined reference to `__gmpz_init'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr<__gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, long, __gmp_binary_multiplies> >, long, __gmp_binary_multiplies> >, long, __gmp_binary_modulus> >(__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, long, __gmp_binary_multiplies> >, long, __gmp_binary_multiplies> >, long, __gmp_binary_modulus> > const&)':
a.cc:(.text._ZN10__gmp_exprIA1_12__mpz_structS1_EC2I17__gmp_binary_exprIS_IS1_S4_IS_IS1_S4_IS2_l23__gmp_binary_multipliesEElS5_EEl20__gmp_binary_modulusEEERKS_IS1_T_E[_ZN10__gmp_exprIA1_12__mpz_structS1_EC5I17__gmp_binary_exprIS_IS1_S4_IS_IS1_S4_IS2_l23__gmp_binary_multipliesEElS5_EEl20__gmp_binary_modulusEEERKS_IS1_T_E]+0x18): undefined reference to `__gmpz_init'
/usr/bin/ld: /tmp/ccU5bANH.o: in function `__gmp_expr<__mpz_struct [1], __mpz_struct [1]>::__gmp_expr<__gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_binary_multiplies> >, long, __gmp_binary_modulus> >(__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __gmp_binary_expr<__gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>, __gmp_binary_multiplies> >, long, __gmp_binary_modulus> > const&)':
a.cc:(.text._ZN10__gmp_exprIA1_12__mpz_structS1_EC2I17__gmp_binary_exprIS_IS1_S4_IS2_S2_23__gmp_binary_multipliesEEl20__gmp_binary_modulusEEERKS_IS1_T_E[_ZN10__gmp_exprIA1_12__mpz_structS1_EC5I17__gmp_binary_exprIS_IS1_S4_IS2_S2_23__gmp_binary_multipliesEEl20__gmp_binary_modulusEEERKS_IS1_T_E]+0x18): undefined reference to `__gmpz_init'
collect2: error: ld returned 1 exit status