stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cmath>

using namespace  std;



int main()

{

    int x,y,z;

    while(cin>>x>>y>>z)

    {

        if(abs(y-x)>=abs(z-x))

        {

            cout<<"B"<<endl;

        }

        else cout<<"A"<<endl;

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.31273419212753x):
#include <stdio.h>

int main(){

	int x, tokoA, tokoB, o, p;

	scanf("%d %d %d", &x, &tokoA, &tokoB);

	o= tokoA - x;

	p= tokoB - x;

	if(o<0){

		o=o*(-1);

	} 

	if(p<0){

		p=p*(-1);

	}

	if(o>p){

		printf("B\n");

	}else if (o<p){

		printf("A\n");

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

using namespace  std;



int main()

{

    int x,y,z;

    while(cin>>x>>y>>z)

    {

        if(abs(y-x)>=abs(z-x))

        {

            cout<<"B"<<endl;

        }

        else cout<<"A"<<endl;

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.311637674683083x):
#include <stdio.h>

int main (){

	int lokasi, a, b, x, y;

	//lokasi rumah, toko a, toko b 

	scanf ("%d %d %d", &lokasi, &a , &b);

	

	x= a- lokasi; 

	y= b- lokasi; 

	if (x<0){

	x=-1*(x);

	}

	if (y<0){

	

	y=-1*(y);

	}

	if (x< y){

	printf ("A");

	}else{

	

	printf ("B");

}

	

	return 0; 

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

using namespace  std;



int main()

{

    int x,y,z;

    while(cin>>x>>y>>z)

    {

        if(abs(y-x)>=abs(z-x))

        {

            cout<<"B"<<endl;

        }

        else cout<<"A"<<endl;

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.324210629404056x):
#include <stdio.h>



int main() {

  int line, store1, store2;

  scanf("%d %d %d", &line, &store1, &store2);

  int distA = (line > store1) ? line - store1 : store1 - line;

  int distB = (line > store2) ? line - store2 : store2 - line;

  (distA < distB) ? puts("A") : puts("B");

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main ()

{

    int x,a,b;

    cin>>x>>a>>b;

    a=x-a;

    a=abs(a);

    b=x-b;

    b=abs(b);

    if(a>b)

        cout<<"B";

    else

        cout<<"A";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.309774172002995x):
#include <stdio.h>



int main() {

  int line, store1, store2;

  scanf("%d %d %d", &line, &store1, &store2);

  int distA = (line > store1) ? line - store1 : store1 - line;

  int distB = (line > store2) ? line - store2 : store2 - line;

  (distA < distB) ? puts("A") : puts("B");

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

void meal(int x,int a,int b){

       if(abs(x-a)<abs(x-b)){

        cout<<"A"<<endl;

       }

       if(abs(x-b)<abs(x-a)){

        cout<<"B"<<endl;

       }

}

int main(){

   int x,a,b;

   cin>>x>>a>>b;

   meal(x,a,b);

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.304859030871038x):
#include <stdio.h>

int main() {

	int x, a, b;

	scanf("%d %d %d",&x,&a,&b);

	

	int ax = 0;

	if (x > a)

	{

		ax = x - a;

	}

	else

	{

		ax = a - x;

	}

	

	int bx = 0;

	if (x > b)

	{

		bx = x - b;

	}

	else

	{

		bx = b - x;

	}

	

	if (ax > bx)

	{

		printf("B\n");

	}

	else 

	{

		printf("A\n");

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

void meal(int x,int a,int b){

       if(abs(x-a)<abs(x-b)){

        cout<<"A"<<endl;

       }

       if(abs(x-b)<abs(x-a)){

        cout<<"B"<<endl;

       }

}

int main(){

   int x,a,b;

   cin>>x>>a>>b;

   meal(x,a,b);

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2751498064966515x):
#include <stdio.h>



int main() {

  int X, A, B;

  scanf("%d %d %d", &X, &A, &B);

  int distA = (X > A) ? X - A : A - X;

  int distB = (X > B) ? X - B : B - X;

  printf("%c\n", (distA < distB) ? 'A' : 'B');

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

void meal(int x,int a,int b){

       if(abs(x-a)<abs(x-b)){

        cout<<"A"<<endl;

       }

       if(abs(x-b)<abs(x-a)){

        cout<<"B"<<endl;

       }

}

int main(){

   int x,a,b;

   cin>>x>>a>>b;

   meal(x,a,b);

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3043633779766x):
#include<stdio.h>

#include<math.h>

int main(){

	int home,a,b;

	scanf("%d%d%d",&home,&a,&b);

	if(abs(home - a ) < abs(home - b)) printf("A\n");

	else printf("B\n");

	

	

	

 	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

void meal(int x,int a,int b){

       if(abs(x-a)<abs(x-b)){

        cout<<"A"<<endl;

       }

       if(abs(x-b)<abs(x-a)){

        cout<<"B"<<endl;

       }

}

int main(){

   int x,a,b;

   cin>>x>>a>>b;

   meal(x,a,b);

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3048953410292095x):
#include <stdio.h>

#include <math.h>



int main() {

	int x,A,B;

	scanf("%d %d %d", &x, &A, &B);

	int da = abs(A-x);

	int db= abs(B-x);

	

	

	if(da < db){

		printf("A");

	}

	else{

		printf("B");

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

void meal(int x,int a,int b){

       if(abs(x-a)<abs(x-b)){

        cout<<"A"<<endl;

       }

       if(abs(x-b)<abs(x-a)){

        cout<<"B"<<endl;

       }

}

int main(){

   int x,a,b;

   cin>>x>>a>>b;

   meal(x,a,b);

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.317283145218946x):
#include <stdio.h>





int main() {

	int x, a, b;

	

	scanf("%d %d %d", &x, &a, &b);

	

	int rangeA = (x > a)? (x - a) : (a - x);

	int rangeB = (x > b)? (x - b) : (b - x);

	

	(rangeA < rangeB)? puts("A") : puts("B");

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

void meal(int x,int a,int b){

       if(abs(x-a)<abs(x-b)){

        cout<<"A"<<endl;

       }

       if(abs(x-b)<abs(x-a)){

        cout<<"B"<<endl;

       }

}

int main(){

   int x,a,b;

   cin>>x>>a>>b;

   meal(x,a,b);

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.317429223901859x):
#include <stdio.h>



int main() {

  int W, A, B;

  scanf("%d %d %d", &W, &A, &B);

  int distA = (W > A) ? W - A : A - W;

  int distB = (W > B) ? W - B : B - W;

  (distA < distB) ? puts("A") : puts("B");

  return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;



typedef long long ll;



const int N = 1e5 + 5, Mod = 1e9 + 7;

int n, m;

ll fact[N];



int main() {

  ios::sync_with_stdio(false);

  cin >> n >> m;

  int offset = abs(n - m);

  fact[0] = 1;

  for (int i = 1; i < N; ++i)

    fact[i] = fact[i - 1] * i % Mod;

  if (offset > 1)

    cout << 0 << endl;

  else if (offset == 1) {

    cout << fact[m] * fact[n] % Mod << endl;

  } else

    cout << fact[m] * fact[n] * 2LL % Mod << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.056262584367916x):
#include<cstdio>

#include<cstdlib>

using namespace std;

typedef long long ll;

const int mod=1e9+7;

int n,m;

ll ans;

inline int abs(int x){return (x>0)?x:-x;}

inline void init(){

	scanf("%d%d",&n,&m);

	if (abs(n-m)>1) {

		puts("0");

		exit(0);

	} 

}

inline void solve(){

	ans=1;

	for (int i=1;i<=n;i++){

		(ans*=i)%=mod;

	}

	for (int i=1;i<=m;i++){

		(ans*=i)%=mod;

	}

	if (n==m) ans=ans*2%mod;

	printf("%lld\n",ans);

}

int main(){

	init();

	solve();

	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;



typedef long long ll;



const int N = 1e5 + 5, Mod = 1e9 + 7;

int n, m;

ll fact[N];



int main() {

  ios::sync_with_stdio(false);

  cin >> n >> m;

  int offset = abs(n - m);

  fact[0] = 1;

  for (int i = 1; i < N; ++i)

    fact[i] = fact[i - 1] * i % Mod;

  if (offset > 1)

    cout << 0 << endl;

  else if (offset == 1) {

    cout << fact[m] * fact[n] % Mod << endl;

  } else

    cout << fact[m] * fact[n] * 2LL % Mod << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7836475398611544x):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://arc076.contest.atcoder.jp/tasks/arc076_a>

問題文============================================================

 すぬけ君は、犬を N 匹と猿を M 匹飼っています。すぬけ君は、この N+M 匹を一列に並べようと思っています。

 

 文字通り犬猿の仲の犬たちと猿たちを仲直りさせたいすぬけ君は、

 犬同士、または猿同士が隣り合うところができないように並べようと思っています。

 

 このような並べ方は何通りあるでしょうか。

 犬と猿は 10^9+7 以上の数を理解できないので、並べ方の個数を 10^9+7 で割ったあまりを求めてください。

 ただし、犬同士、また猿同士は互いに区別します。また、左右が反転しただけの列も異なる列とみなします。

=================================================================



解説=============================================================



 良くある組み合わせ問題

 

 NとMの差が２以上であれば、交互に配置することができないので 1

 差が1であれば、 N!*M!

 差が0であれば 2*N!*M!

================================================================

*/

const ll MOD = 1e9+7;

int main(void) {

	cin.tie(0); ios::sync_with_stdio(false);

    ll N,M; cin >> N >> M;

    ll ans = 1;

    if(abs(N-M)>=2){

        ans = 0;

    }else if(abs(N-M)==1){

        if(M < N) swap(N,M);

        for(ll i = 1; i <= N; i++){

            (ans *= i)%=MOD;

        }

        ans = (ans * ((ans*M)%MOD))%MOD;

    }else{

        for(ll i = 1; i <= N; i++){

            (ans *= i)%=MOD;

        }

        ans = (((ans * ans)%MOD)*2)%MOD;

    }

    cout << ans << endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



using LL = long long;



#define MOD (7 + (int)1e9)



vector<LL> f(100000);



LL factorial(LL k){

    f[1] = 1;

    for (int i = 1; i <= k; ++i)

    {

        f[i+1] = (f[i] * (i+1)) % MOD;

    }

    return f[k] % MOD;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    LL N, M;



    cin >> N >> M;



    LL res;

    if(labs(N-M) >= 2){

        cout << 0 << endl;

        return 0;

    }else if(labs(N-M) == 1){

        res = ((factorial(N) % MOD) * (factorial(M) % MOD)) % MOD;

    }else{

        res = ((factorial(N) % MOD) * (factorial(M) % MOD) * 2) % MOD;

    }



    cout << res << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8124123248255841x):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://arc076.contest.atcoder.jp/tasks/arc076_a>

問題文============================================================

 すぬけ君は、犬を N 匹と猿を M 匹飼っています。すぬけ君は、この N+M 匹を一列に並べようと思っています。

 

 文字通り犬猿の仲の犬たちと猿たちを仲直りさせたいすぬけ君は、

 犬同士、または猿同士が隣り合うところができないように並べようと思っています。

 

 このような並べ方は何通りあるでしょうか。

 犬と猿は 10^9+7 以上の数を理解できないので、並べ方の個数を 10^9+7 で割ったあまりを求めてください。

 ただし、犬同士、また猿同士は互いに区別します。また、左右が反転しただけの列も異なる列とみなします。

=================================================================



解説=============================================================



 良くある組み合わせ問題

 

 NとMの差が２以上であれば、交互に配置することができないので 1

 差が1であれば、 N!*M!

 差が0であれば 2*N!*M!

================================================================

*/

const ll MOD = 1e9+7;

int main(void) {

	cin.tie(0); ios::sync_with_stdio(false);

    ll N,M; cin >> N >> M;

    ll ans = 1;

    if(abs(N-M)>=2){

        ans = 0;

    }else if(abs(N-M)==1){

        if(M < N) swap(N,M);

        for(ll i = 1; i <= N; i++){

            (ans *= i)%=MOD;

        }

        ans = (ans * ((ans*M)%MOD))%MOD;

    }else{

        for(ll i = 1; i <= N; i++){

            (ans *= i)%=MOD;

        }

        ans = (((ans * ans)%MOD)*2)%MOD;

    }

    cout << ans << endl;

	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;



typedef long long ll;



const int N = 1e5 + 5, Mod = 1e9 + 7;

int n, m;

ll fact[N];



int main() {

  ios::sync_with_stdio(false);

  cin >> n >> m;

  int offset = abs(n - m);

  fact[0] = 1;

  for (int i = 1; i < N; ++i)

    fact[i] = fact[i - 1] * i % Mod;

  if (offset > 1)

    cout << 0 << endl;

  else if (offset == 1) {

    cout << fact[m] * fact[n] % Mod << endl;

  } else

    cout << fact[m] * fact[n] * 2LL % Mod << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.050008895086831x):
#include<stdio.h>

#include<cmath>

using namespace std;

#define mod 1000000007

#define MOD(x) ((x)%mod)

long long n,m;

long long ans(long long x)

{

	long long a=1;

	for(long long i=1;i<=x;i++)

		a=MOD(a*i);

	return a;

}

int main()

{

	scanf("%lld%lld",&n,&m);

	if(abs(n-m)>=2)

	{

		printf("0");

	}

	else if(abs(n-m)==1)

	{

		printf("%lld",MOD(ans(n)*ans(m)));

	}

	else

	{

		printf("%lld",MOD(ans(n)*ans(m)*2));

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



using LL = long long;



#define MOD (7 + (int)1e9)



vector<LL> f(100000);



LL factorial(LL k){

    f[1] = 1;

    for (int i = 1; i <= k; ++i)

    {

        f[i+1] = (f[i] * (i+1)) % MOD;

    }

    return f[k] % MOD;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    LL N, M;



    cin >> N >> M;



    LL res;

    if(labs(N-M) >= 2){

        cout << 0 << endl;

        return 0;

    }else if(labs(N-M) == 1){

        res = ((factorial(N) % MOD) * (factorial(M) % MOD)) % MOD;

    }else{

        res = ((factorial(N) % MOD) * (factorial(M) % MOD) * 2) % MOD;

    }



    cout << res << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 9.195957886676062x):
#include<stdio.h>

#include<cmath>

using namespace std;

#define mod 1000000007

#define MOD(x) ((x)%mod)

long long n,m;

long long ans(long long x)

{

	long long a=1;

	for(long long i=1;i<=x;i++)

		a=MOD(a*i);

	return a;

}

int main()

{

	scanf("%lld%lld",&n,&m);

	if(abs(n-m)>=2)

	{

		printf("0");

	}

	else if(abs(n-m)==1)

	{

		printf("%lld",MOD(ans(n)*ans(m)));

	}

	else

	{

		printf("%lld",MOD(ans(n)*ans(m)*2));

	}

	return 0;

}
// Slower C++ solution:
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

const int INF = 1e9;

const ll LINF = 1e18;



/*

<url:https://arc076.contest.atcoder.jp/tasks/arc076_a>

問題文============================================================

 すぬけ君は、犬を N 匹と猿を M 匹飼っています。すぬけ君は、この N+M 匹を一列に並べようと思っています。

 

 文字通り犬猿の仲の犬たちと猿たちを仲直りさせたいすぬけ君は、

 犬同士、または猿同士が隣り合うところができないように並べようと思っています。

 

 このような並べ方は何通りあるでしょうか。

 犬と猿は 10^9+7 以上の数を理解できないので、並べ方の個数を 10^9+7 で割ったあまりを求めてください。

 ただし、犬同士、また猿同士は互いに区別します。また、左右が反転しただけの列も異なる列とみなします。

=================================================================



解説=============================================================



 良くある組み合わせ問題

 

 NとMの差が２以上であれば、交互に配置することができないので 1

 差が1であれば、 N!*M!

 差が0であれば 2*N!*M!

================================================================

*/

const ll MOD = 1e9+7;

int main(void) {

	cin.tie(0); ios::sync_with_stdio(false);

    ll N,M; cin >> N >> M;

    ll ans = 1;

    if(abs(N-M)>=2){

        ans = 0;

    }else if(abs(N-M)==1){

        if(M < N) swap(N,M);

        for(ll i = 1; i <= N; i++){

            (ans *= i)%=MOD;

        }

        ans = (ans * ((ans*M)%MOD))%MOD;

    }else{

        for(ll i = 1; i <= N; i++){

            (ans *= i)%=MOD;

        }

        ans = (((ans * ans)%MOD)*2)%MOD;

    }

    cout << ans << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.073877373660559x):
#include<stdio.h>

#include<cmath>

using namespace std;

#define mod 1000000007

#define MOD(x) ((x)%mod)

long long n,m;

long long ans(long long x)

{

	long long a=1;

	for(long long i=1;i<=x;i++)

		a=MOD(a*i);

	return a;

}

int main()

{

	scanf("%lld%lld",&n,&m);

	if(abs(n-m)>=2)

	{

		printf("0");

	}

	else if(abs(n-m)==1)

	{

		printf("%lld",MOD(ans(n)*ans(m)));

	}

	else

	{

		printf("%lld",MOD(ans(n)*ans(m)*2));

	}

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define LL long long

#define MEM(x,y) memset(x,y,sizeof(x))

#define MOD(x) ((x)%mod)

#define mod 1000000007

#define pb push_back

#define STREAM_FAST ios::sync_with_stdio(false)



using namespace std;

const int maxn = 1e5+7;

LL f[maxn];

int main()

{

    f[0]=1;for (int i=1;i<=100000;i++) f[i]=MOD(f[i-1]*i);

    

    int n,m;scanf("%d%d",&n,&m);

    LL ans;

    if (abs(n-m)>1) ans=0;

    else if (abs(n-m)==1) ans=MOD(f[n]*f[m]);

    else if (n==m) ans=MOD(2*f[n]*f[m]);

    printf("%lld\n",ans);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 8.962172382003354x):
#include<stdio.h>

#include<cmath>

using namespace std;

#define mod 1000000007

#define MOD(x) ((x)%mod)

long long n,m;

long long ans(long long x)

{

	long long a=1;

	for(long long i=1;i<=x;i++)

		a=MOD(a*i);

	return a;

}

int main()

{

	scanf("%lld%lld",&n,&m);

	if(abs(n-m)>=2)

	{

		printf("0");

	}

	else if(abs(n-m)==1)

	{

		printf("%lld",MOD(ans(n)*ans(m)));

	}

	else

	{

		printf("%lld",MOD(ans(n)*ans(m)*2));

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<bits/stdc++.h>

#define ll long long

#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

ll p[100009], mod=1000000007;

ll n, m ;

int main()

{

	IO;

	p[0]=1;

	for (int i=1; i<=100000; i++)

		p[i]=(i*p[i-1])%mod;

	cin>>n>>m;

	if (abs(n-m)>1)

		return cout<<0, 0;

	if (abs(n-m)==1)

		cout<<(p[n]*p[m])%mod;

	else

		cout<<((2*p[n]*p[m])%mod);

}


// Faster C++ solution for the same problem (measured speedup: 1.1640381739124241x):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<int, pii> pipii;

typedef pair<pii, pii> piipii;



#define mp make_pair

#define fi first

#define se second

#define all(a) (a).begin(), (a).end()

#define sz(a) (int)(a).size()

#define eb emplace_back

const int mod = 1e9+7;

ll f[100005];

int main(){

    f[0] = 1;

    for(int i=1;i<=100000;i++) f[i] = f[i-1]*i%mod;

    int a, b;

    scanf("%d%d", &a, &b);   

    if(a < b) swap(a, b);

    if(a-b >= 2) printf("0\n");

    else{

        ll ans;

        if(a-b == 1) ans = f[a]*f[b]%mod;

        else ans = f[a]*f[b]%mod*2%mod;

        printf("%lld\n", ans);

    }

}
// Slower C++ solution:
#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

using namespace std;

long long f[123456];

#define mod 1000000007;

int main(){

	int n,m;

	f[1]=1;

	for(int i=2;i<=100000;i++){

		f[i]=(i*f[i-1])%mod;

		

	}//printf("%lld\n",f[2]);

//	printf("%lld\n",f[100000]);

	while(~scanf("%d%d",&n,&m)){

		long long ans=0;

		if(abs(n-m)>2){

			printf("0\n");

		}

		else{

			if(abs(n-m)==1){

				ans+=f[n]*f[m]%mod;

			}

			if(abs(n-m)==0){

				ans+=f[n]*f[m]*2%mod;

			}

			printf("%lld\n",ans);

		}

		

		

	}

		

	

	return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 4.926833682173858x):
#include<stdio.h>

#include<string.h>

#include<string>

#include<math.h>

#include<map>

#include<vector>

#include<queue>

#include<set>

#include<algorithm>

#define MAX 1000000007

using namespace std;

int main(){

    int n,m;

    while(~scanf("%d%d",&n,&m)){

        long long ans=1;

        if(n-m>1||m-n>1){

            printf("0\n");

        }

        else{

            if(n==m){

                for(int i=2;i<=n;i++){

                    ans=(ans*i)%MAX;

                    ans=(ans*i)%MAX;

                }

                ans=(ans*2)%MAX;

            }

            else{

                int pp;

                if(m<n){

                    pp=n;

                    n=m;

                    m=pp;

                }

                for(int i=2;i<=n;i++){

                    ans=(ans*i)%MAX;

                    ans=(ans*i)%MAX;

                }

                ans=(ans*m)%MAX;

            }

            printf("%lld\n",ans);

        }

    }

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



using VI = vector<int>;

using VVI = vector<VI>;

using PII = pair<int, int>;

using LL = long long;

using VL = vector<LL>;

using VVL = vector<VL>;

using PLL = pair<LL, LL>;

using VS = vector<string>;



#define ALL(a)  begin((a)),end((a))

#define RALL(a) (a).rbegin(), (a).rend()

#define PB push_back

#define EB emplace_back

#define MP make_pair

#define SZ(a) int((a).size())

#define SORT(c) sort(ALL((c)))

#define RSORT(c) sort(RALL((c)))

#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))



#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define REP(i,n)  FOR(i,0,n)



#define FF first

#define SS second

template<class S, class T>

istream& operator>>(istream& is, pair<S,T>& p){

  return is >> p.FF >> p.SS;

}

template<class S, class T>

ostream& operator<<(ostream& os, const pair<S,T>& p){

  return os << p.FF << " " << p.SS;

}

template<class T>

void maxi(T& x, T y){

  if(x < y) x = y;

}

template<class T>

void mini(T& x, T y){

  if(x > y) x = y;

}





const double EPS = 1e-10;

const double PI  = acos(-1.0);

const LL MOD = 1e9+7;



int main(){

  cin.tie(0);

  ios_base::sync_with_stdio(false);



  LL N, M;

  cin >> N >> M;



  VL fact(100010);

  fact[0] = 1;

  for(LL i=1;i<100010;++i)

	fact[i] = (fact[i-1] * i) % MOD;



  if(abs(N-M) > 1){

	cout << 0 << endl;

  }

  else if(N == M){

	cout << fact[N] * fact[M] * 2 % MOD << endl;

  }

  else{

	if(N > M) swap(N, M);

	cout << fact[N] * fact[M] % MOD << endl;

  }



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.3348961017952585x):
#include <iostream>

using namespace std;

typedef long long ll;

int main()

{

    ll n,m;

    cin>>n>>m;

    if(abs(n-m)>1)

    {

        cout<<0<<endl;

        return 0;

    }

    if(n==m)

    {

    ll brojac=1;

    for(ll i=1;i<=n;i++)

    {

        brojac*=i;

        brojac%=1000000007;

    }

    for(ll i=1;i<=n;i++)

    {

        brojac*=i;

        brojac%=1000000007;

    }

    brojac*=2;

    brojac%=1000000007;

    cout<<brojac<<endl;

    }

    else

    {

        ll brojac=1;

        if(n<m)

            swap(n,m);

        for(ll i=1;i<=n;i++)

    {

        brojac*=i;

        brojac%=1000000007;

    }

    for(ll i=1;i<=m;i++)

    {

        brojac*=i;

        brojac%=1000000007;

    }

    cout<<brojac<<endl;

    }

    return 0;

}