s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s215144450
p03681
u852790844
1586640634
Python
Python (3.4.3)
py
Runtime Error
17
3060
255
N = 10**6 mod = 10**9 + 7 fact = [1] for i in range(1, N+1): fact.append(fact[-1]*n%mod) n, m = map(int, input()) ans = 0 if n - m > 1 or m - n > 1: ams = 0 elif n - m == 0: ans = 2 * (fact[n])**2 else: ans = fact[n] * fact[m) print(ans)
s293084254
p03681
u852790844
1586640490
Python
Python (3.4.3)
py
Runtime Error
17
2940
255
n = 10**6 mod = 10**9 + 7 fact = [1] for i in range(1, n+1): fact.sppend(fact[-1]*n%mod) n, m = map(int, input()) ans = 0 if n - m > 1 or m - n > 1: ams = 0 elif n - m == 0: ans = 2 * (fact[n])**2 else: ans = fact[n] * fact[m) print(ans)
s351271255
p03681
u038408819
1586387770
Python
Python (3.4.3)
py
Runtime Error
17
3064
394
N, M = map(int, input().split()) mod = 10**9 + 7 if abs(N - M) > 1: print(0) elif abs(N - M) == 0: ans = mod_factorial(N, mod) * mod_factorial(M, mod) * 2 print(ans % mod) else: ans = mod_factorial(N, mod) * mod_factorial(M, mod) print(ans % mod) def mod_factorial(a, mod): ans = 1 while a !=...
s373283986
p03681
u920621778
1586131313
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38256
281
def test(): mod = 10**9 + 7 n, m = map(int, input().split()) if abs(n-m) > 1: print(0) exit() t_l = max([n, m]) p_l = 1 for i in range(t_l): if i == t_l-1: break p = p * (t_l-i) p_s = p / t_l s = 2 if n == m else 1 r = (p_l*p_s*s) % (10**9 + 7) print(r) test()
s029989861
p03681
u828728147
1586129024
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
332
hoge = 10 ** 9 + 7 def test(): n, m = map(int, input().split()) if abs(n-m) > 1: print(0) exit() i_n = n i_m = m np = 1 mp = 1 for i in range(1,i_n) np = np * i_n for i in range(1,i_m) mp = mp * i_m s = 2 if n == m else 1 r = (mp % hoge) * (np % hoge) * (s % hoge) print(r) if __name__ == '__main__'...
s003935194
p03681
u828728147
1586128340
Python
PyPy3 (2.4.0)
py
Runtime Error
187
38512
341
def main() n, m = map(int, input().split()) if abs(n-m) > 1: print(0) exit() i_n = n i_m = m np = 1 mp = 1 while True: np = np * i_n mp = mp * i_m i_n -= 1 i_m -= 1 if i_n < 1: i_n = 1 if i_m < 1: i_m = 1 if i_n == 1 and i_m == 1: break s = 2 if n == m else 1 r = (mp*np*s) % (10**9 +...
s361290700
p03681
u828728147
1586128232
Python
Python (3.4.3)
py
Runtime Error
17
3064
341
def main() n, m = map(int, input().split()) if abs(n-m) > 1: print(0) exit() i_n = n i_m = m np = 1 mp = 1 while True: np = np * i_n mp = mp * i_m i_n -= 1 i_m -= 1 if i_n < 1: i_n = 1 if i_m < 1: i_m = 1 if i_n == 1 and i_m == 1: break s = 2 if n == m else 1 r = (mp*np*s) % (10**9 +...
s239824177
p03681
u263753244
1585577464
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38384
123
n,m=map(int,input().split()) import math if abs(n-m) > 1: print(0) else: print(math.factorial(n)*math.factorial(m)
s854157674
p03681
u291628833
1585107117
Python
PyPy3 (2.4.0)
py
Runtime Error
2112
133384
241
n,m = map(int,input().split()) MOD = 10**9+7 def kaijo(i): ans = 1 for i in range(1,i+1): ans *= i%MOD return ans if abs(m-n) == 1: ans = kaijo(n) * kaijo(m) elif n == m: ans = 2*kaijo(n) * kaijo(m) print(ans)
s947685844
p03681
u291628833
1585106970
Python
PyPy3 (2.4.0)
py
Runtime Error
2111
133384
241
n,m = map(int,input().split()) def kaijo(i): ans = 1 for i in range(1,i+1): ans *= i return ans if abs(m-n) == 1: ans = kaijo(n) * kaijo(m) elif n == m: ans = 2*kaijo(n) * kaijo(m) mod = 10**9+7 print(ans%mod)
s765644664
p03681
u287500079
1585044997
Python
Python (3.4.3)
py
Runtime Error
51
7064
293
import math mod=10**9+7 factorial=[1 for _ in range(10**5+10)] for i in range(1, 10**5+10): factorial[i]=i*factorial[i-1] % mod n,m=map(int,input().split()) if abs(n-m)>1: print(0) elif abs(n-m)==0: print(2*factorial[n]*factorial[m]) else: print(factorial[n]*math.factorial[m])
s336136345
p03681
u547167033
1584992158
Python
Python (3.4.3)
py
Runtime Error
17
3060
219
from math import factorial n,m=map(int,input().split()) mod=10**9+7 if abs(n-m)>=2: print(0) elif abs(n-m)==1: print((factorial(n,mod)*factorial(m,mod))%mod) else: print((2*factortial(n,mod)*factorial(m,mod))%mod)
s509380001
p03681
u107269063
1584217169
Python
Python (3.4.3)
py
Runtime Error
18
3064
228
import math n,m = map(int,input().split()) rev = 10**9+7 if n-m==0: ans = 2 * math.factorial(n) * math.factorial(m) elif (abs(n-m)==1): ans = 1 * math.factorial(n) : math.factorial(m) else: ans = 0 print(ans%rev)
s579089857
p03681
u530383736
1584143411
Python
Python (3.4.3)
py
Runtime Error
55
3060
330
# -*- coding: utf-8 -*- N,M = list(map(int, input().rstrip().split())) #----- divisor = 10**9 + 7 cnt=1 diff = abs(N-M) if diff >=2: print("0") sys.exit() else: for num in [N,M]: for i in range(1,num+1): cnt = (cnt * i) % divisor if diff == 0: cnt = (cnt * 2) % divisor p...
s089524272
p03681
u038815010
1583980169
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38384
178
import math n,m=map(int,input().split()) mod=10**9+7 a=math.factorial(n)*math.factorial(m) if abs(n-m)==0: print(2*a%mod) exit() elif abs(n-m)>1: a=0 print(a%mod)
s360206494
p03681
u105302073
1583331261
Python
Python (3.4.3)
py
Runtime Error
700
5164
236
from math import factorial n, m = [int(i) for i in input().split()] mod = 10e9 + 7 ans = 0 diff = abs(n - m) if diff == 0: ans = (factorial(n) ** 2) * 2 % mod elif diff == 1: ans = factorial(n) * factorial(m) % mod print(ans)
s475171330
p03681
u046592970
1582160608
Python
Python (3.4.3)
py
Runtime Error
62
3316
277
import sys n,m = map(int,input().split()) if abs(n-m) >= 2: print(0) sys.exit() if abs(n-m) == 1: x = max(a,b) for i in range(1,min(n,m)+1): x = x*i**2 % (10**9 + 7) else: x = 2 for i in range(1,n+1): x = x*i**2 % (10**9 + 7) print(x)
s724601573
p03681
u644360640
1580236437
Python
Python (3.4.3)
py
Runtime Error
2106
89808
305
import sys sys.setrecursionlimit(100000) n,m = map(int,input().split()) diff = abs(n-m) def saiki(n): if n<=1: return 1 return n * saiki(n-1) if diff >= 2: print(0) elif diff == 1: print((saiki(max(n,m))*saiki(min(n,m)))%(10**9+7)) else: print((saiki(n)*saiki(m)*2)%(10**9+7))
s834906578
p03681
u644360640
1580236398
Python
Python (3.4.3)
py
Runtime Error
82
11708
304
import sys sys.setrecursionlimit(10000) n,m = map(int,input().split()) diff = abs(n-m) def saiki(n): if n<=1: return 1 return n * saiki(n-1) if diff >= 2: print(0) elif diff == 1: print((saiki(max(n,m))*saiki(min(n,m)))%(10**9+7)) else: print((saiki(n)*saiki(m)*2)%(10**9+7))
s503988546
p03681
u835924161
1580235478
Python
Python (3.4.3)
py
Runtime Error
17
3060
212
n,m=map(int,input().split()) if abs(n-m)>1: print(0) ans=int(1) for i in range(1,n+1): ans*=i for i in range(1,m+1): ans*=i if n==m: ans*=2 if abs(n-m)>1: ans=0 print(ans%=1000000007)
s992950241
p03681
u027929618
1579836391
Python
Python (3.4.3)
py
Runtime Error
17
2940
175
from math import factorial n,m=map(int,input().split()) mod=10**9+7 f=factorial(n) if abs(n-m)>1: print(0) elif abs(n-m)==1: print((f**2)%mod) else : print((2*f**2%mod)
s909700767
p03681
u119655368
1577207010
Python
Python (3.4.3)
py
Runtime Error
17
3060
238
a, b = map(int, input().split()) if abs(a - b) >= 2: print(0) else: x = math.factorial(a) y = math.factorial(b) ans = x * y if a == b: print(ans * 2 % (10 ** 9 + 7)) else: print(ans % (10 ** 9 + 7))
s808105455
p03681
u225388820
1577051311
Python
Python (3.4.3)
py
Runtime Error
17
2940
257
def lam(x,mod): ans=1 for i in range(1,x+1): ans*=i ans%=mod return ans n,m=map(int,input().split()) n,m=min(n,m),max(n,m) mod=10**9+7 if n<m-1: print(0) exit() if n+1==m: print(lam(n,mod)*lam(m,mod)%mod) else: print(2*(lam(n,mod)**2)
s581593549
p03681
u225388820
1577050970
Python
Python (3.4.3)
py
Runtime Error
17
2940
252
def lam(x,mod): ans=1 for i in range(1,x+1): ans*=i ans%=mod return ans n,m=map(int,input().split()) n,m=min(n,m),max(n,m) mod=10**9+7 if n<m-1: print(0) exit() if n+1==m: print(lam(n,mod)*lam(m,mod)%mod) else: print(2*(lam(n,mod)**2)
s982673321
p03681
u225388820
1577048829
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38256
257
def lam(x,mod): ans=1 for i in range(1,x+1): ans*=i ans%=mod return ans n,m=map(int,input().split()) n,m=min(n,m),max(n,m) mod=10**9+7 if n<m-1: print(0) exit() if n+1==m: print(lam(n,mod)*lam(m,mod)%mod) else: print(2*(lam(n,mod)**2)%mod)
s793804152
p03681
u225388820
1577048786
Python
PyPy3 (2.4.0)
py
Runtime Error
163
38384
255
def lam(x,mod): ans=1 for i in range(1,x+1): ans*=i ans%=mod return ans n,m=map(int,input().split()) n,m=min(n,m),max(n,m) mod=10**9+7 if n<m-1: print(0) exit() if n+1==m: print(lam(n,mod)*lam(m,mod)%mod) else: print(2*lam(n,mod)**2%mod)
s813542491
p03681
u225388820
1577048527
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38384
255
def lam(x,mod): ans=1 for i in range(1,x+1): ans*=i ans%=mod return ans n,m=map(int,input().split()) n,m=min(n,m),max(n,m) mod=10**9+7 if n<m-1: print(0) exit() if n+1==m: print(lam(n,mod)*lam(m,mod)%mod) else: print(2*lam(n,mod)**2%mod)
s786721371
p03681
u225388820
1577048482
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
239
def lam(x): ans=1 for i in range(1,x+1): ans*=i ans%=mod return ans n,m=map(int,input().split()) n,m=min(n,m),max(n,m) mod=10**9+7 if n<m-1: print(0) exit() if n+1==m: print(lam(n)*lam(m)%mod) else: print(2*lam(n)**2%mod)
s042131529
p03681
u577993490
1575381568
Python
Python (3.4.3)
py
Runtime Error
577
17980
692
import numpy as np import scipy as sp import math def main(): # parse N, M = parse(get_stdin()) # compute result = compute(N, M) # show result print(result) def compute(N, M): a = abs(N - M) if a >= 2: return 0 elif a == 1: return math.factorial(N) + math.factorial(...
s135219888
p03681
u577993490
1575381493
Python
Python (3.4.3)
py
Runtime Error
581
13568
692
import numpy as np import scipy as sp import math def main(): # parse N, M = parse(get_stdin()) # compute result = compute(N, M) # show result print(result) def compute(N, M): a = abs(N - M) if a >= 2: return 0 elif a == 1: return math.factorial(N) + math.factorial(...
s710822935
p03681
u577993490
1575381410
Python
Python (3.4.3)
py
Runtime Error
576
15024
692
import numpy as np import scipy as sp import math def main(): # parse N, M = parse(get_stdin()) # compute result = compute(N, M) # show result print(result) def compute(N, M): a = abs(N - M) if a >= 2: return 0 elif a == 1: return math.factorial(N) + math.factorial(...
s447699714
p03681
u295520101
1574149625
Python
Python (3.4.3)
py
Runtime Error
17
3060
170
from math import factorial a,b=int(input().split()) if (abs(a-b)>1): print(0) elif (a==b): print((factorial(a)*4)%1000000007) else: print(facorial(a)*factorial(b))
s184710113
p03681
u923659712
1574124524
Python
Python (3.4.3)
py
Runtime Error
17
2940
207
import math n,m=map(int,input().split()) if n=m+1 or m=n+1: print((math.factorial(n)*math.factorial(m))%(10**9+7)) elif n=m: print(((math.factorial(n)*math.factorial(m))*2)%(10**9+7)) else: print(0)
s859294563
p03681
u905203728
1571941691
Python
Python (3.4.3)
py
Runtime Error
18
3064
445
n,m=map(int,input().split()) cnt=1 def plot(): if cnt>=10**9+7: cnt %=10**9+7 return cnt if abs(n-m)>1:print(0);exit() elif (n+m)%2==1: for i in range(n): cnt *=(i+1) plot() for j in range(m): cnt *=(j+1) plot() print(cnt) else: cnt *=(n+m) n -=1 f...
s005965758
p03681
u076917070
1571720308
Python
PyPy3 (2.4.0)
py
Runtime Error
160
38256
484
import sys input = sys.stdin.readline def main(): N, M = map(int, input().split()) mod = (10**9)+7 if abs(N-M) >= 2: print(0) else: ans = 1 for n in range(1, N+1): ans = ans * n % mod for m in range(1, M+1): ...
s773460959
p03681
u796942881
1571613828
Python
Python (3.4.3)
py
Runtime Error
40
3572
540
from functools import reduce INF = int(1e9 + 7) def modmulti(a, b): # aとbを掛けた値をmodする(a * b mod p) return a * b % INF def factorial(x): FCT = 1 FCT = reduce(modmulti, range(2, x + 1)) return FCT def main(): N, M = map(int, input().split()) MIN_NM = factorial(min(N, M)) if N == M or ...
s607852607
p03681
u379959788
1569778745
Python
Python (3.4.3)
py
Runtime Error
179
14376
324
from scipy.special import comb import math mod = 10**9 + 7 N, M = map(int, input().split()) if abs(N - M) > 1: print(0) else: if abs(N - M) == 1: print(((math.factorial(N) % mod) * (math.factorial(M) % mod)) % mod) else: print(((math.factorial(N) % mod) * ((math.factorial(M) * 2) % mod)) % ...
s940027520
p03681
u668503853
1568169206
Python
Python (3.4.3)
py
Runtime Error
702
5304
183
import math mod=1000000007 N,M=map(int,input().split()) if abs(N-M)>1: print(0) else: n=math.factorial(N) m=math.factorial(M) if n==m: print(2*n*m%mod) else: print(n*m%mod)
s254349359
p03681
u598229387
1567885716
Python
Python (3.4.3)
py
Runtime Error
703
5180
194
import math n,m=map(int,input().split()) if abs(n-m)>=2: ans=0 else: nn=math.factorial(n) mm=math.factorial(m) ans = nn*mm print(ans%(10**9+7) if nn !=mm else (ans*2)%(10**9+7))
s236468970
p03681
u598229387
1567885511
Python
Python (3.4.3)
py
Runtime Error
2104
3468
244
n,m=map(int,input().split()) if abs(n-m)>=2: ans=0 else: check=1 check2=1 while n >=1: check *= n n-=1 while m>=1: check2 *=m m-=1 ans=check*check2 print(ans if check !=check2 else ans*2)
s699142445
p03681
u518987899
1567143267
Python
Python (3.4.3)
py
Runtime Error
150
13204
375
from functools import lru_cache import sys sys.setrecursionlimit(10000) N,M = map(int, input().strip().split(' ')) @lru_cache(maxsize=512) def factorial(n): if n in {0,1}: return 1 return n*factorial(n-1) % 1000000007 if abs(N-M) >= 2: print(0) elif N == M: print(factorial(N)*factorial(M)*2 % 1000000007)...
s597915727
p03681
u503228842
1566497769
Python
Python (3.4.3)
py
Runtime Error
2107
89792
320
import sys sys.setrecursionlimit(10**5) def my_factorial(n): if n == 0: return 1 else: return n * my_factorial(n-1) N,M = map(int,input().split()) if abs(N-M) >= 2: print(0) elif abs(N-M) == 1: print(my_factorial(N) * my_factorial(M)) else: print(2*my_factorial(N)*my_factorial(M))
s883752018
p03681
u503228842
1566497758
Python
Python (3.4.3)
py
Runtime Error
17
2940
130
/home/hiroya/.pyenv/versions/anaconda3-5.3.1/bin/python /home/hiroya/06_coding/aaa.py 4 4 1152 Process finished with exit code 0
s615049696
p03681
u626337957
1564836671
Python
Python (3.4.3)
py
Runtime Error
49
6900
203
N, M = map(int, input().split()) if abs(N-M) > 1: print(0) else: num = max(N, M) dp = [1] * (num+1) for i in range(2, num+1): dp[i] = (i * dp[i-1])%(10**9+7) print((dp[N]*dp[M])%(10**9+7))
s437847019
p03681
u177756077
1564016148
Python
Python (3.4.3)
py
Runtime Error
2104
3484
221
N,M=map(int,input().split()) div=10**9+7 tmp=1 K=min(N,M) diff=abs(N-M) for i in range(K): tmp*=(i+1)%div if diff>3: ans=0 elif diff==0: ans=2*tmp*tmp%div elif diff==1: ans=tmp*(tmp+K+1+1)%div print(ans)
s937590225
p03681
u224050758
1561085774
Python
Python (3.4.3)
py
Runtime Error
17
2940
389
N, M = [int(s) for s in input().split()] def main(): n = N m = M d = 1_000_000_007 if abs(n - m) > 1: print(0) return n, m = (m, n) if n > m else (n, m) ans = 1 for i in range(1, n + 1): ans *= i ** 2 ans = ans % d last_n = 2 if n == m else m ans = an...
s279715831
p03681
u543954314
1560289009
Python
Python (3.4.3)
py
Runtime Error
17
2940
78
from math import factorial as f print(max(0,2-abs(n-m))*f(n)*f(m) % (10**9+7))
s613947859
p03681
u027002244
1560032904
Python
Python (3.4.3)
py
Runtime Error
231
4084
324
import math a=list(map(int,input().split())) ans=0 if max(a)-min(a)>=2: print(0) else: if a[0]==a[1]: ans=math.factorial(max(a)) ans=(ans%1000000007)*(ans%1000000007)*2 else: ans=math.factorial(max(a)) ans=(ans%1000000007)*((ans/max(a))%1000000007) print(int(ans%100000000...
s721081469
p03681
u027002244
1560032057
Python
Python (3.4.3)
py
Runtime Error
400
4604
291
import math a=list(map(int,input().split())) ans=0 if max(a)-min(a)>=2: print(0) else: if a[0]==a[1]: ans=math.factorial(max(a)) ans=ans*ans*2 else: ans=math.factorial(max(a)) ans=ans*ans/max(a) #print(ans) print(int(ans%1000000007 ))
s338468691
p03681
u027002244
1560031468
Python
Python (3.4.3)
py
Runtime Error
399
4608
287
import math a=list(map(int,input().split())) ans=0 i=0 if max(a)-min(a)>=2: pass else: if a[0]==a[1]: ans=math.factorial(max(a)) ans=ans*ans*2 else: ans=math.factorial(max(a)) ans=ans*ans/max(a) #print(ans) print(int(ans%1000000007 ))
s462887030
p03681
u083668616
1559856102
Python
PyPy3 (2.4.0)
py
Runtime Error
174
38256
234
def fct(n): v = 1 for i in range(1, n+1): v = (v * i) % 1000000007 return v N, M = map(int, input().split()) ans = 0 if N == M: v = fct(N) ans = (v*v*2)%1000000007 elif abs(N-M) == 1: ans = (fct(N)*fct(M))%1000000007 print ans
s279563974
p03681
u623687794
1559421953
Python
Python (3.4.3)
py
Runtime Error
74
3948
237
m,d=map(int,input().split()) def fac(n): a=1 if n==1: return a else: a=n*fac(n-1) return a%(10**9+7) if abs(m-d)>=2: print(0) elif abs(m-d)==1: print((fac(m)*fac(d))%(10**9+7)) else: print(2*(fac(m)**2)%(10**9+7))
s174593942
p03681
u271469978
1558757834
Python
Python (3.4.3)
py
Runtime Error
17
2940
370
n, m = map(int, input().split()) mod = 10 ** 9 + 7 def n_factorial_mod(n, mod): ret = 1 while n != 1: ret = ret * n % mod n -= 1 return ret if abs(n - m) > 1: print(0) elif abs(n - m) == 1: print(n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mod) else: print(2 * n_facto...
s067590706
p03681
u163320134
1558559842
Python
Python (3.4.3)
py
Runtime Error
17
2940
280
n,m=map(int,input().split()) if abs(n-m)>=2 ans=0 elif abs(n-m)==1: ans=1 for i in range(1,n+1): ans=(ans*i)%(10**9+7) for j in range(1,m+1): ans=(ans*j)%(10**9+7) else: ans=1 for i in range(1,n+1): ans=(ans*i)%(10**9+7) ans=(ans**2)%(10**9+7) print(ans)
s202433057
p03681
u163320134
1558559665
Python
Python (3.4.3)
py
Runtime Error
17
2940
280
n,m=map(int,input().split()) if abs(n-m)>=2 ans=0 elif abs(n-m)==1: ans=1 for i in range(1,n+1): ans=(ans*i)%(10**9+7) for j in range(1,m+1): ans=(ans*i)%(10**9+7) else: ans=1 for i in range(1,n+1): ans=(ans*i)%(10**9+7) ans=(ans**2)%(10**9+7) print(ans)
s134157286
p03681
u856169020
1557497030
Python
Python (3.4.3)
py
Runtime Error
17
3060
221
N, M = int(int, input().split()) def kaizyo(n): if n == 1: return n return n * (n-1) if N == M: print(2 * kaizyo(N) * kaizyo(M)) else: if abs(N-M) == 1: print(kaizyo(N) * kaizyo(M)) else: print(0)
s849268586
p03681
u518042385
1556761979
Python
Python (3.4.3)
py
Runtime Error
18
3060
175
import math n,m=map(int,input().split()) a=math.factrial(n) b=math.factrial(m) if n==m: print((2*a**2)%(10**9+7)) elif abs(n-m)==1: print((a*b)%(10**9+7)) else: print(0)
s212935565
p03681
u518042385
1556761765
Python
Python (3.4.3)
py
Runtime Error
18
2940
211
def fact(n): if n==1: return 1 else: return n*fact(n-1) n,m=map(int,input().split()) if n==m: print(2*(fact(n))**2%(10**9+7)) elif abs(n-m)=1: print(fact(n)*fact(m)%(10**9+7)) else: print(0)
s772135058
p03681
u969190727
1556161328
Python
Python (3.4.3)
py
Runtime Error
73
3900
159
def f(n): if n==1: return 1 else: return f(n-1)*n n,m=map(int,input().split()) ans=f(m)*f(n) if n==m: ans*=2 elif abs(n-m)>1: ans=0 print(ans)
s171728690
p03681
u623819879
1555563201
Python
Python (3.4.3)
py
Runtime Error
73
3892
249
import sys sys.setrecursionlimit mo=10**9+7 def fact(x): if x==0: return 1 else: return x*fact(x-1)%mo n,m=map(int,input().split()) if abs(n-m)>1: print(0) elif m==n: print((2*fact(m)*fact(n))%mo) else: print((fact(m)*fact(n))%mo)
s818487471
p03681
u623819879
1555563130
Python
Python (3.4.3)
py
Runtime Error
74
3892
216
mo=10**9+7 def fact(x): if x==0: return 1 else: return x*fact(x-1)%mo n,m=map(int,input().split()) if abs(n-m)>1: print(0) elif m==n: print((2*fact(m)*fact(n))%mo) else: print((fact(m)*fact(n))%mo)
s786489542
p03681
u623819879
1555563038
Python
Python (3.4.3)
py
Runtime Error
72
3888
216
mo=10**9+7 def fact(x): if x==1: return 1 else: return x*fact(x-1)%mo n,m=map(int,input().split()) if abs(n-m)>1: print(0) elif m==n: print((2*fact(m)*fact(n))%mo) else: print((fact(m)*fact(n))%mo)
s763704994
p03681
u623819879
1555562965
Python
Python (3.4.3)
py
Runtime Error
74
3892
214
mo=10**9+7 def fact(x): if x==1: return 1 else: return x*fact(x-1)%mo n,m=map(int,input().split()) if abs(n-m)>1: print(0) elif m==n: print((fact(m)*fact(n)*2)%mo) else: print(fact(m)*fact(n)%mo)
s567489316
p03681
u623819879
1555560160
Python
Python (3.4.3)
py
Runtime Error
72
3896
210
mo=10**9+7 def fact(x): if x==1: return 1 else: return x*fact(x-1)%mo n,m=map(int,input().split()) if abs(n-m)>1: print(0) elif m==n: print((fact(m)*fact(n)*2)%mo) else: print(fact(m)*fact(n))
s578439488
p03681
u635182517
1555531789
Python
Python (3.4.3)
py
Runtime Error
400
4736
225
import math N, M = map(int, input().split()) N, M = max(N,M), min(N,M) MOd = 10**9+7 if N == M: ans = math.factorial(N) ** 2 * 2 elif N - M == 1: ans = math.factorial(M) ** 2 * N else: ans = 0 print(ans // MOD)
s669672779
p03681
u655975843
1555286757
Python
Python (3.4.3)
py
Runtime Error
2278
90992
687
import sys import collections sys.setrecursionlimit(100000) ns = lambda: sys.stdin.readline().rstrip() ni = lambda: int(ns()) nm = lambda: map(int, sys.stdin.readline().split()) nl = lambda: list(nm()) nsl = lambda: map(str, sys.stdin.readline().split()) n, m = nm() memo = [-1 for i in range(max(n, m) + 1)] mod = 10 *...
s727655011
p03681
u187205913
1554953093
Python
Python (3.4.3)
py
Runtime Error
17
3060
174
a,b = map(int,input().spilit()) import math if a==b: print(math.factorial(a)**2*2%(10**9+7)) elif abs(a-b)==1: print(math.factorial(a)*math.factorial(b)) else: print(0)
s661893065
p03681
u844646164
1554859652
Python
Python (3.4.3)
py
Runtime Error
441
4092
398
import math n, m = map(int, input().split()) MOD = 1000000007 a, b = n, m count_n = n count_m =m count = 0 if abs(n-m) == 1: count_n = math.factorial(n) / MOD count_m = math.factorial(m) / MOD count = count_m * count_n % MOD elif abs(n-m) == 0: count_n = math.factorial(n) % MOD count_m = math.factorial(m) % M...
s496793333
p03681
u013408661
1554247434
Python
Python (3.4.3)
py
Runtime Error
17
2940
145
import math n,m=map(int,input().split()) if abs(n-m)>1: print(0) exit() p=10**9+7 print((2*((math.factorial(m))%)*((math.factorial(m))%))%p)
s895815010
p03681
u210827208
1553755585
Python
Python (3.4.3)
py
Runtime Error
399
4740
191
import math n,m=map(int,input().split()) if n==m-1 or n==m+1: print((math.factorial(m)*math.factorail(n))%(1e9+7)) elif n==m: print((2*(math.factorial(m)**2))%(1e9+7)) else: print(0)
s681540209
p03681
u210827208
1553755531
Python
Python (3.4.3)
py
Runtime Error
229
4020
190
import math n,m=map(int,input().split()) if n==m-1 or n==m+1: print((math.factorial(m)*math.factorail(n))%(1e9+7)) elif n==m: print((2*(math.factorail(m)**2))%(1e9+7)) else: print(0)
s730183210
p03681
u677440371
1553395467
Python
Python (3.4.3)
py
Runtime Error
18
2940
142
X,A,B = map(int, input().split()) if A + X < B: print("dengerous") if A <= B <= A + X: print("safe") if B < A: print("delicious")
s171975437
p03681
u887207211
1552644000
Python
Python (3.4.3)
py
Runtime Error
17
2940
264
A, B = map(int,input().split()) mod = 10**9+7 def factorical(n): ret = 1 for i in range(1,n+1): ret *= i ret %= return ret%mod a = factorical(A) b = factorical(B) if(abs(A-B) >= 2): print(0) elif(A == B): print(a*b*2%mod) else: print(a*b%mod)
s118382349
p03681
u887207211
1552643925
Python
Python (3.4.3)
py
Runtime Error
49
3064
287
A, B = map(int,input().split()) def factorical(n): ret = 1 for i in range(1,n+1): ret *= i%(10**9+7) ret %= (10**9+7) return ret%(10**9+7) a = factorical(A) b = factorical(B) if(abs(M-N)>= 2): print(0) elif(A == B): print(a*b*2%(10**9+7)) else: print(a*b%(10**9+7))
s151585190
p03681
u393512980
1551935964
Python
Python (3.4.3)
py
Runtime Error
40
3064
425
MOD = 10**9 + 7 def Mod_Permutation(n, k, mod): ret = 1 for i in range(n - k + 1, n + 1): ret = ret * i % mod return ret N, M = map(int, input().split()) if abs(N - M) > 1: print(0) elif N == M: print(int(Mod_Permutation(N, N, MOD) * (2 * Mod_Permutation(N, M, MOD) % MOD) % MOD)) else: i...
s376033387
p03681
u393512980
1551931959
Python
Python (3.4.3)
py
Runtime Error
30
3060
230
MOD = 10**9 + 7 def Mod_Permutation(n, k, mod): ret = 1 for i in range(n - k + 1, n + 1): ret = ret * i % mod return ret N, M = map(int, input().split()) print(Mod_Permutation(N, N, MOD) * P(N+1, M, MOD) % MOD)
s496317657
p03681
u543954314
1550778042
Python
Python (3.4.3)
py
Runtime Error
73
3900
228
def a(n): if n < 2: return 1 return a(n-1) * n n, m = map(int, input().split()) if abs(n-m) > 1: print(0) elif abs(n-m) == 1: print(a(n) * a(m) % 1000000007) else: print(2 * a(n) * a(m) % 1000000007)
s878401983
p03681
u309977459
1548371977
Python
Python (3.4.3)
py
Runtime Error
18
3060
203
import math.factorial as F N, M = map(int, input().split()) N, M = min(N, M), max(N, M) mod = 10**9+7 if M-N > 1: print(0) elif M-N == 1: print(F(M)*F(N) % mod) else: print(F(M)**2*2 % mod)
s142842923
p03681
u785578220
1547839628
Python
Python (3.4.3)
py
Runtime Error
18
3060
151
import math a,b = ma() mod = 10**9 + 7 m = max(a,b) n = min(a,b) k=math.factorial(m) if m!=n: print(((k**2)*m)%mod) else: print(((k**2)*2)%mod)
s676484521
p03681
u067983636
1540506308
Python
Python (3.4.3)
py
Runtime Error
53
6900
298
N, M = map(int, input().split()) mod = 10 ** 9 + 7 K = max(N, M) kaijo = [1] * (K + 1) for i in range(K): kaijo[i + 1] = ((i + 1) * kaijo[i]) % mod if abs(N - M) > 1: print(0) else: res = 1 res *= kaijo[N] * kaijo[M] if N == M: res *= 2 print(res % mod)
s898492880
p03681
u031178961
1540042187
Python
Python (3.4.3)
py
Runtime Error
17
2940
636
#include <iostream> using namespace std; using ll = long long; const int INF = 1e9; #define put(n) cout<<(n)<<endl #define rep(i,N) for(int(i)=0;(i)<(N);++(i)) #define rrep(i,N) for(int (i)=(N-1);(i)>=(0);--(i)) #define all(v) (v).begin() , (v).end() #define rall(v) (v).rbegin() , (v).rend() #define pb(n) push_back(n) ...
s034201992
p03681
u940102677
1539973287
Python
Python (3.4.3)
py
Runtime Error
17
2940
257
n,m = map(int,input().split()) if n<m: n,m = m,n if n == m: s = 1 for in range(1,m+1): s = s*i%1000000007 s = s*s*2%1000000007 elif n == m+1: s = 1 for for in range(1,m+1): s = s*i%1000000007 s = s*s*n%1000000007 else: s = 0 print(s)
s481012029
p03681
u102902647
1536902763
Python
Python (3.4.3)
py
Runtime Error
17
2940
391
# -*- coding: utf-8 -*- """ Created on Fri Sep 14 01:10:44 2018 @author: Yuki """ mod = 1000000000 + 7 def func(n): r = 1 for i in range(1, n+1): r *= i r %= mod return r N, M = map(int, input().1split()) if abs(N-M) > 1: print(0) elif abs(N-M) == 1: A = max(N, M) res = func(A)...
s425238614
p03681
u102902647
1536902429
Python
Python (3.4.3)
py
Runtime Error
2106
89812
398
# -*- coding: utf-8 -*- """ Created on Fri Sep 14 01:10:44 2018 @author: Yuki """ import sys sys.setrecursionlimit(100001) def func(n): if n == 0 or n == 1: return 1 else: return n*func(n-1) N, M = map(int, input().split()) if abs(N-M) > 1: print(0) elif abs(N-M) == 1: A = max(N, M) ...
s834760867
p03681
u102902647
1536902216
Python
Python (3.4.3)
py
Runtime Error
77
3896
349
# -*- coding: utf-8 -*- """ Created on Fri Sep 14 01:10:44 2018 @author: Yuki """ def func(n): if n == 0 or n == 1: return 1 else: return n*func(n-1) N, M = map(int, input().split()) if abs(N-M) > 1: print(0) elif abs(N-M) == 1: A = max(N, M) res = func(A) print(int(res**2/A)) ...
s065940170
p03681
u201234972
1535492620
Python
Python (3.4.3)
py
Runtime Error
36
3188
382
Q = 10**9 + 7 ''' def factorial(n): if n == 0: return 1 else: return (n * factorial(n-1))%Q ''' N, M = map( int, input().split()) N, M = min(N, M), max(N, M) if N == M or N+1 == M: NN = 1 MM = 1 for i in range(1,N+1): NN = (NN*i)%Q if N == M: ans = (2*NN*NN)%Q eli...
s265621253
p03681
u599547273
1533367230
Python
Python (3.4.3)
py
Runtime Error
17
2940
187
import math n, m = map(int, input().split(" ")) remain = abs(n-m) if remain <= 1: print((math.factorial(n) * math.factorial(m) * (2 if remain==0 else 1)) % (10**9+7))) else: print(0)
s378545478
p03681
u599547273
1533367191
Python
Python (3.4.3)
py
Runtime Error
17
2940
185
import math n, m = map(int, input().split(" ")) remain = abs(n-m) if remain <= 1: print(math.factorial(n) * math.factorial(m) * (2 if remain==0 else 1)) % (10**9+7)) else: print(0)
s037120723
p03681
u143492911
1517768673
Python
Python (3.4.3)
py
Runtime Error
26
3060
211
n,m=map(int,input().split()) mod=10**9+7 sn=1 for i in range(n+1): sn*=i for j in range(m+1): sm*=j if 2<=abs(n-m): print(0) elif abs(n-m)==1: print(sn*sm) elif n==m: print(2*sn*sm)
s529420808
p03681
u863684580
1517265188
Python
PyPy2 (5.6.0)
py
Runtime Error
35
27756
248
lights = [int(raw_input()) for i in range(int(raw_input()))] lamps = [0]*len(lights) lamps[0] = 1 lampco = len(set(lights)) for i in xrange(len(lamps)): lamps[int(lights[i])-1] += 1 if lamps[1] == 1: print i exit() print -1
s111347589
p03681
u789417951
1513915003
Python
Python (3.4.3)
py
Runtime Error
74
3896
261
N, M =map(int,input().split()) ans=0 def fact(n): if n==0: return 1 return n*fact(n-1) if abs(N-M)>=2: print(0) elif abs(N-M)==0: ans=fact(N)*4 elif abs(N-M)==1: ans=fact(N)*fact(M) else: print(0) ans=ans%(10**9+7) print(ans)
s250504432
p03681
u789417951
1513914939
Python
Python (3.4.3)
py
Runtime Error
18
3188
261
N, M =map(int,input().split()) ans=0 def fact(n): if n==0: return1: return n*fact(n-1) if abs(N-M)>=2: print(0) elif abs(N-M)==0: ans=fact(N)*4 elif abs(N-M)==1: ans=fact(N)*fact(M) else: print(0) ans=ans%(10**9+7) print(ans)
s819500938
p03681
u495415554
1511500153
Python
Python (3.4.3)
py
Runtime Error
25
3684
582
import functools import operator N, M = map(int, input().split()) sub = abs(N - M) @profile def main(N, M, sub): if sub > 1: # 解なし print("0") else: m = max(N, M) n = min(N, M) per_a = 1 for i in range(n): per_a *= (i+1) per_b = per_a ...
s712754512
p03681
u495415554
1511497485
Python
Python (3.4.3)
py
Runtime Error
18
3060
392
import itertools N, M = input().split() sub = abs(N - M) if sub > 1: # 解なし print("0") else: a = [i for i in range(N)] b = [i for i in range(M)] per_a = len(list(itertools.permutations(a))) per_b = len(list(itertools.permutations(b))) if sub == 1: ans = per_a * per_b print(...
s635994564
p03681
u612721349
1505264309
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38384
209
n, m = map(int, input().split()) if -2 < (n - m) < 2: ans = 1 for i in range(n): ans *= n ans %= 10_0000_0007 for i in range(m): ans *= n ans %= 10_0000_0007 print(ans) else: print(0)
s071772177
p03681
u612721349
1505264204
Python
Python (3.4.3)
py
Runtime Error
16
2940
208
n, m = map(int, input().split()) if -2 < (n -m) < 2: ans = 1 for i in range(n): ans *= n ans %= 10_0000_0007 for i in range(m): ans *= n ans %= 10_0000_0007 print(ans) else: print(0)
s808878979
p03681
u762008592
1503504283
Python
Python (3.4.3)
py
Runtime Error
17
3064
261
def kai(x): k=1 for i in range(1,x+1): k*=i return k A=kai(a) B=kai(b) import sys a,b=map(int,input().split()) ans=0 if a==b+1 or b==a+1: ans=A*B%(10**9+7) elif b==a: ans=2*A*B%(10**9+7) else: print(0) sys.exit() print(ans)
s159415739
p03681
u290326033
1500789116
Python
Python (3.4.3)
py
Runtime Error
81
4728
452
N, M = list(map(int, input().split())) dp = [0]*(max(N, M)+1) mod = 10000007 def factorical(n): if dp[n] != 0: rec = dp[n] elif n == 1: rec = 1 else: rec = n*factorical(n-1) dp[n] = rec % mod return rec factorical(max(N, M)) if abs(N-M) > 1: print(0) elif N == M: dog =...
s511839453
p03681
u351527281
1499953905
Python
Python (3.4.3)
py
Runtime Error
18
3188
269
import math n,m = map(int, input().split()) if abs(n-m) <= 1: a = max(n,m) b = min(n,m) if a-b == 1: print((math.factorial(a)*math.factorial(b))%(10**9+7)) else: print((math.factorial(a)*math.factorial(b)*2%(10**9+7)) else: print(0)
s454611037
p03681
u343437894
1499643621
Python
Python (3.4.3)
py
Runtime Error
73
3884
288
n, m = map(int, input().split(" ")) (n, m) = (n, m) if n>m else (m, n) M=1000000007 def newfact(n): return ((n * newfact(n-1)) % M if n > 1 else 1) if n > m+1: print(0) elif n == m: print((2 * newfact(n) * newfact(m)) % M) else: print((newfact(n) * newfact(m)) % M)