s_id
string
p_id
string
u_id
string
date
string
language
string
original_language
string
filename_ext
string
status
string
cpu_time
string
memory
string
code_size
string
code
string
error
string
stdout
string
s987187315
p04046
u353797797
1586397889
Python
Python (3.4.3)
py
Runtime Error
576
63168
2242
from itertools import permutations import sys sys.setrecursionlimit(10 ** 6) from bisect import * from collections import * from heapq import * def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline()[:-1] def LLI(rows_number): return [LI() for _ in range(rows_number)] int1 = lambda x: int(x) - 1 def MI1(): return map(int1, sys.stdin.readline().split()) def LI1(): return list(map(int1, sys.stdin.readline().split())) p2D = lambda x: print(*x, sep="\n") dij = [(1, 0), (0, 1), (-1, 0), (0, -1)] # grobalにmdを設定すること class mint: def __init__(self, x): self.__x = x % md def __str__(self): return str(self.__x) def __neg__(self): return mint(-self.__x) def __add__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x + other) def __sub__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x - other) def __rsub__(self, other): return mint(other - self.__x) def __mul__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x * other) __radd__ = __add__ __rmul__ = __mul__ def __truediv__(self, other): if isinstance(other, mint): other = other.__x return mint(self.__x * pow(other, md - 2, md)) def __rtruediv__(self, other): return mint(other * pow(self.__x, md - 2, md)) def __pow__(self, power, modulo=None): return mint(pow(self.__x, power, md)) md = 10**9+7 def nCr(com_n, com_r): if com_n < com_r: return 0 return fac[com_n] * ifac[com_r] * ifac[com_n - com_r] n_max = 100005 fac = [mint(1)] for i in range(1, n_max + 1): fac.append(fac[-1] * i) ifac = [mint(1)] * (n_max + 1) ifac[n_max] /= fac[n_max] for i in range(n_max - 1, 1, -1): ifac[i] = ifac[i + 1] * (i + 1) def main(): h,w,a,b=MI() cc=[] for i in range(h-a): cc.append(nCr(b+i,i)) #print(*cc) ans=mint(0) pc=0 for i,c in enumerate(cc): ans+=(c-pc)*nCr(h-1-i+w-1-b,w-1-b) pc=c print(ans) main()
Traceback (most recent call last): File "/tmp/tmploki_fjh/tmpa2pcof5k.py", line 85, in <module> main() File "/tmp/tmploki_fjh/tmpa2pcof5k.py", line 73, in main h,w,a,b=MI() ^^^^^^^ ValueError: not enough values to unpack (expected 4, got 0)
s399167431
p04046
u114233208
1586325227
Python
Python (3.4.3)
py
Runtime Error
97
11184
1495
import math # Function to find modulo inverse of b. It returns # -1 when inverse doesn't # modInverse works for prime m def modInverse(b,m): g = math.gcd(b, m) if (g != 1): # print("Inverse doesn't exist") return -1 else: # If b and m are relatively prime, # then modulo inverse is b^(m-2) mode m return pow(b, m - 2, m) # Function to compute a/b under modulo m def modDivide(a,b,m): a = a % m inv = modInverse(b,m) if(inv == -1): print("Division not defined") else: return (inv*a) % m MOD = (10 ** 9) + 7 H, W, A, B = list(map(int, input().split(' '))) DP = [] j = 1 for i in range(1,200002): j *= i j %= MOD DP.append(j) # print(DP) def factorial(i): if (i == 0): return 1 global DP # print(i) # print(i, DP[i-1]) # print(DP[i-1]) return DP[i-1] def move2(H, W, A, B): numPaths = 0 h = H-A w = W-(W-B)+1 a = A+1 pttp = 0 for b in range(w, W+1): # print(h, b, a, W-b+1) ttp = (factorial(h+b-2)*modInverse((factorial(h-1)*factorial(b-1))% MOD, MOD)) % MOD tpttp = ttp ttp -= pttp pttp = tpttp btp = (factorial(a+(W-b+1)-2)*modInverse((factorial(a-1)*factorial(W-b))% MOD, MOD)) % MOD # btp = factorial(a+(W-b+1)-2)//(factorial(a-1)*factorial(W-b)) numPaths += ttp*btp return numPaths ways = move2(H, W, A, B) print(ways % (10**9 + 7))
Traceback (most recent call last): File "/tmp/tmp9s6whfek/tmptibye6my.py", line 27, in <module> H, W, A, B = list(map(int, input().split(' '))) ^^^^^^^ EOFError: EOF when reading a line
s261480853
p04046
u292978925
1585420107
Python
Python (3.4.3)
py
Runtime Error
154
15560
992
from operator import mul from functools import reduce def cmb(n, r, p): if (r < 0) or (n < r): return 0 r = min(r, n - r) return fact[n] * factinv[r] * factinv[n-r] % p p = 10 ** 9 + 7 N = 10 ** 5 fact = [1, 1] # fact[n] = (n! mod p) factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) inv = [0, 1] for i in range(2, N + 1): fact.append((fact[-1] * i) % p) inv.append((-inv[p % i] * (p // i)) % p) factinv.append((factinv[-1] * inv[-1]) % p) #kari1 = '2 3 1 1' #2 #kari1 = '10 7 3 4' #3570 #kari1 = '100000 100000 99999 99999' #1 #kari1 = '100000 100000 44444 55555' #738162020 """ in1 = kari1.split() """ in1 = input().split() H = int(in1[0]) W = int(in1[1]) A = int(in1[2]) B = int(in1[3]) allCNT = 0 for idx1 in range(W - B): beforeCNT = cmb(H - A + B - 1 + idx1, H - A - 1, p) afterCNT = cmb(W + A - B - 2 - idx1, A - 1, p) allCNT = (allCNT + (beforeCNT * afterCNT) % p) % p print(allCNT)
Traceback (most recent call last): File "/tmp/tmpzvd2by9y/tmppqui53xe.py", line 29, in <module> in1 = input().split() ^^^^^^^ EOFError: EOF when reading a line
s235834284
p04046
u595353654
1585417610
Python
Python (3.4.3)
py
Runtime Error
79
7844
895
from sys import stdin from operator import itemgetter ##stdin = open("sample.txt") H,W,A,B = [int(x) for x in stdin.readline().rstrip().split()] def fact(a): if a == 0: return 1 elif a == 1: return a else: return a * fact(a-1) path_list = list(range(W-B)) path_list2 = list(range(0)) path_list.reverse() for path in path_list: path_list2.append(fact((W-path-1)+(H-A-1))//fact(W-path-1)//fact(H-A-1)) H2 = A+1 W2 = W-B path2_list = [[0] * (W2) for i in range(H2)] h = 0 w = 0 while h < H2: path2_list[h][0] = path_list2[0] h += 1 while w < W2: path2_list[0][w] = path_list2[w] w += 1 h2 = 1 w2 = 1 ans = 0 while h2 <= H2-1 and w2 <= W2-1: ans = (path2_list[h2-1][w2] + path2_list[h2][w2-1]) path2_list[h2][w2] = ans if w2 == W2-1: h2 += 1 w2 = 1 else: w2 += 1 print(path2_list[H2-1][W2-1])
Traceback (most recent call last): File "/tmp/tmpj29kw1cj/tmpn56s0ig3.py", line 5, in <module> H,W,A,B = [int(x) for x in stdin.readline().rstrip().split()] ^^^^^^^ ValueError: not enough values to unpack (expected 4, got 0)
s922047891
p04046
u595353654
1585417135
Python
Python (3.4.3)
py
Runtime Error
80
7844
846
from sys import stdin from operator import itemgetter #stdin = open("sample.txt") H,W,A,B = [int(x) for x in stdin.readline().rstrip().split()] def fact(a): if a == 1: return a return a * fact(a-1) path_list = list(range(W-B)) path_list2 = list(range(0)) path_list.reverse() for path in path_list: path_list2.append(fact((W-path-1)+(H-A-1))//fact(W-path-1)//fact(H-A-1)) H2 = A+1 W2 = W-B path2_list = [[0] * (W2) for i in range(H2)] h = 0 w = 0 while h < H2: path2_list[h][0] = path_list2[0] h += 1 while w < W2: path2_list[0][w] = path_list2[w] w += 1 h2 = 1 w2 = 1 ans = 0 while h2 <= H2-1 and w2 <= W2-1: ans = (path2_list[h2-1][w2] + path2_list[h2][w2-1]) path2_list[h2][w2] = ans if w2 == W2-1: h2 += 1 w2 = 1 else: w2 += 1 print(path2_list[H2-1][W2-1])
Traceback (most recent call last): File "/tmp/tmpgyuvpd0s/tmpbqmhb8z9.py", line 5, in <module> H,W,A,B = [int(x) for x in stdin.readline().rstrip().split()] ^^^^^^^ ValueError: not enough values to unpack (expected 4, got 0)
s575061516
p04046
u050087249
1583889991
Python
Python (3.4.3)
py
Runtime Error
2219
1831028
641
H, W, A, B = list(map(int, input().split())) up = [[0]*W for i in range(H-A)] down = [[0]*(W-B) for i in range(A)] #上側ここから for i in range(1, W): up[0][i] = 1 for j in range(1, H-A): up[j][0] = 1 for i in range(1, H-A): for j in range(1, W): up[i][j] = up[i-1][j] + up[i][j-1] #下側ここから down[0][0] = up[H-(A+1)][B] for i in range(1, W-B): down[0][i] = up[H-(A+1)][B+i] + down[0][i-1] for j in range(1, A): down[j][0] = down[j-1][0] for j in range(1, A): for i in range(1, W-B): down[i][j] = down[i-1][j] + down[i][j-1] #print(up) #print(down) output = down[A-1][W-(B+1)] % (10**9+7) print(output)
Traceback (most recent call last): File "/tmp/tmpfslogase/tmp0rth0jfx.py", line 1, in <module> H, W, A, B = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s292953273
p04046
u941407962
1582896185
Python
PyPy3 (2.4.0)
py
Runtime Error
215
58096
1100
import sys mod = pow(10, 9) + 7 sys.setrecursionlimit(pow(10, 8)) def power(x, y): if y == 0: return 1 elif y == 1 : return x % mod elif y % 2 == 0 : return power(x, y//2)**2 % mod else: return power(x, (y-1)//2)**2 * x % mod def mul(a, b): return ((a % mod) * (b % mod)) % mod def div(a, b): return mul(a, power(b, mod-2)) def div2(a, b): return mul(a, modinv(b)) def modinv(a): b, u, v = mod, 1, 0 while b: t = a//b a, u = a-t*b, u-t*v a, b, u, v = b, a, v, u u %= mod return u def cmb(n, r): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod NNN = (10**5) g1 = [1, 1] g2 = [1, 1] inverse = [0, 1] for i in range( 2, NNN + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) H, W, A, B = map(int, input().split()) r = 0 for i in range(H-A): # (0, 0) -> (i, B-1) # (i, B) -> (H-1, W-1) r = (r + mul(cmb(i+B-1, i), cmb(H-1-i+W-1-B, H-1-i)))%mod print(r)
Traceback (most recent call last): File "/tmp/tmpqqosfp_6/tmpo7rfhuqt.py", line 43, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s128645716
p04046
u090198186
1582584001
Python
Python (3.4.3)
py
Runtime Error
2111
135752
673
import sys import numpy as np readline = lambda:sys.stdin.readline().rstrip() def solve(H,W,A,B): a = np.zeros([H,W], dtype=np.int32) a[:-A, 0] = 1 a[0, 1:] = 1 #[1-B) for y in range(1, H-A): a[y, 1:] += a[y-1, 1:] for x in range(1, W): a[y, x] = np.sum(a[y, x-1:x+1]) % (10**9+7) #[B-H) for y in range(H-A, H): a[y, B:] += a[y-1, B:] for x in range(B+1, W): a[y, x] = np.sum(a[y, x-1:x+1]) % (10**9+7) return a def main(): H, W, A, B = [int(s) for s in readline().split()] if H>W: H,W,A,B = W,H,B,A ans = solve(H,W,A,B) print(ans[H-1, W-1]) main()
Traceback (most recent call last): File "/tmp/tmp6ao4ylqz/tmpygfommyj.py", line 30, in <module> main() File "/tmp/tmp6ao4ylqz/tmpygfommyj.py", line 24, in main H, W, A, B = [int(s) for s in readline().split()] ^^^^^^^^^^ ValueError: not enough values to unpack (expected 4, got 0)
s784836799
p04046
u627600101
1581873968
Python
Python (3.4.3)
py
Runtime Error
72
12900
798
import fractions H,W,A,B=map(int,input().split()) mod =10**9+7 def C(n,m): if n*m==0: C =1 else: bunbo=[0]*min(m,n) bunsi=[0]*min(m,n) for k in range(min(m,n)): bunbo[k]=min(m,n)-k bunsi[k]=n+m-k for k in range(min(m,n)): for j in range(min(n,m)): if math.gcd(bunsi[j],bunbo[k])==0: gcd =fractions.gcd(bunsi[j],bunbo[k]) bunsi[j]=bunsi[j]//gcd bunbo[k]=bunbo[k]//gcd if bunbo[k]==1: break C=1 for k in range(min(n,m)): C=C*bunsi[k]%mod return C Total = C(H-1,W-1) dame = 0 for k in range(B): dame += C(k,H-A-1)*C(W-1-k,A-1) answer = (Total-dame)%mod print(answer)
Traceback (most recent call last): File "/tmp/tmpyuvtztmb/tmp97y0r4si.py", line 2, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s820378045
p04046
u627600101
1581870288
Python
Python (3.4.3)
py
Runtime Error
54
10868
710
import math H,W,A,B=map(int,input().split()) def C(n,m): if n*m==0: C =1 else: bunbo=[0]*min(m,n) bunsi=[0]*min(m,n) for k in range(min(m,n)): bunbo[k]=min(m,n)-k bunsi[k]=n+m-k for k in range(min(m,n)): for j in range(min(n,m)): gcd=math.gcd(bunbo[k],bunsi[j]) bunbo[k]=bunbo[k]//gcd bunsi[j]=bunsi[j]//gcd x=1 y=1 for k in range(min(n,m)): x=x*bunsi[k] y=y*bunbo[k] C=x//y return C Total = C(H-1,W-1) dame = 0 for k in range(B): dame += C(k,H-A-1)*C(W-1-k,A-1) answer = (Total-dame)%(10**9+7) print(int(answer))
Traceback (most recent call last): File "/tmp/tmpq002l91t/tmp6kewqkbq.py", line 2, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s715946910
p04046
u627600101
1581870255
Python
Python (3.4.3)
py
Runtime Error
59
10868
710
import math H,W,A,B=map(int,input().split()) def C(n,m): if n*m==0: C =1 else: bunbo=[0]*min(m,n) bunsi=[0]*min(m,n) for k in range(min(m,n)): bunbo[k]=min(m,n)-k bunsi[k]=n+m-k for k in range(min(m,n)): for j in range(min(n,m)): gcd=math.gcd(bunbo[k],bunsi[j]) bunbo[k]=bunbo[k]//gcd bunsi[j]=bunsi[j]//gcd x=1 y=1 for k in range(min(n,m)): x=x*bunsi[k] y=y*bunbo[k] C=x//y return C Total = C(H-1,W-1) dame = 0 for k in range(B): dame += C(k,H-A-1)*C(W-1-k,A-1) answer = (Total-dame)%(10**9+7) print(int(answer))
Traceback (most recent call last): File "/tmp/tmp_mj0ev7j/tmpqqswacq5.py", line 2, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s543108779
p04046
u627600101
1581863224
Python
PyPy3 (2.4.0)
py
Runtime Error
2106
39792
250
H,W,A,B=map(int,input().split()) def C(n,m): C=1 for k in range(m): C = C*(n+m-k)/(m-k) return C Total = C(H-1,W-1) dame = 0 for k in range(B): dame += C(k,H-A-1)*C(W-1-k,A-1) answer = (Total-dame)%(10**9+7) print(int(answer))
Traceback (most recent call last): File "/tmp/tmpc6nhu09b/tmp2r2w969a.py", line 1, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s712810411
p04046
u627600101
1581863004
Python
Python (3.4.3)
py
Runtime Error
2104
3064
250
H,W,A,B=map(int,input().split()) def C(n,m): C=1 for k in range(m): C = C*(n+m-k)/(m-k) return C Total = C(H-1,W-1) dame = 0 for k in range(B): dame += C(k,H-A-1)*C(W-1-k,A-1) answer = (Total-dame)%(10**9+7) print(int(answer))
Traceback (most recent call last): File "/tmp/tmpgo30y4co/tmpxa09nyxn.py", line 1, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s438115515
p04046
u627600101
1581862094
Python
Python (3.4.3)
py
Runtime Error
2104
3508
346
H,W,A,B=map(int,input().split()) H=H-1 W=W-1 A=A-1 B=B-1 def bikkuri(n): m=1 if n >1: for k in range(1,n+1): m = m *k return m def C(n,m): return bikkuri(n+m)/bikkuri(n)/bikkuri(m) Total = C(H,W) dame = 0 for k in range(0,B+1): dame += C(k,H-A-1)*C(W-k,A) answer = (Total-dame)%(10**9+7) print(int(answer))
Traceback (most recent call last): File "/tmp/tmpu828a79a/tmp_5wybx20.py", line 1, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s834530172
p04046
u052221988
1581829763
Python
Python (3.4.3)
py
Runtime Error
2104
3488
455
import math h, w, a, b = map(int, input().split()) count = 0 def combination(n, r) : num_1 = 1 num_2 = 1 for j in range(n-r) : num_1 *= (n-j) num_2 *= (j+1) num_ans = int(num_1 / num_2) return num_ans for i in range(b) : n1 = h-a+i-1 r1 = i n2 = w+a-i-2 r2 = a-1 x = combination(n1, r1) y = combination(n2, r2) count += x*y total = combination(h+w-2, h-1) print(int(total-count)%(10**9+7))
Traceback (most recent call last): File "/tmp/tmplqdxct3t/tmpkymxscoi.py", line 2, in <module> h, w, a, b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s663411055
p04046
u670133596
1581372406
Python
Python (3.4.3)
py
Runtime Error
1407
17972
558
import math # 10, 7, 3, 4 H, W, A, B = map(int, input().split()) # 通らなければいけない点を算出する need = [[B, i] for i in range(1, H-A+1)] ans = 0 for each in need: # 通らなければいけない点までの計算 left = each[0] - 1 top = each[1] - 1 C1 = (math.factorial(top+left))/(math.factorial(top)*math.factorial(left)) # それ以降の計算 left = W - B - 1 top = H - top - 1 C2 = math.factorial((top+left))/(math.factorial(top)*math.factorial(left)) ans += (C1*C2) print(int(ans))
Traceback (most recent call last): File "/tmp/tmpodpfisq6/tmp03uc4d7j.py", line 4, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s816031366
p04046
u686230543
1580703783
Python
Python (3.4.3)
py
Runtime Error
24
7668
441
mod = 10**9 + 7 h, w, a, b = map(int, input().split()) fact = [1] * (h + w + 1) invf = [1] * (h + w + 1) invn = [1] * (h + w + 1) for i in range(1, h + w + 1): fact[i] = fact[i-1] * i % mod invn[i] = -invn[mod % i] * (p // i) % mod invf[i] = invf[i-1] * invn[i] % mod count = 0 for i in range(min(h-a, w-b)): count += fact[h+b-a-1] * invf[h-a-i-1] * invf[b+i] * fact[w+a-b-1] * invf[a+i] * invf[w-b-i-1] count %= mod print(count)
Traceback (most recent call last): File "/tmp/tmpc0hdqmt5/tmp61r0r6wq.py", line 2, in <module> h, w, a, b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s112831411
p04046
u414458988
1579741160
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38256
729
mod = 1000000007 H, W, A, B = map(int, raw_input().split()) factorial = [1] for n in xrange(1, H+W): factorial.append(factorial[n-1]*n%mod) def power(x, y): if y == 0 : return 1 elif y == 1 : return x % mod elif y % 2 == 0 : return power(x, y/2)**2 % mod else : return power(x, y/2)**2 * x % mod inverseFactorial = [0] * (H+W) inverseFactorial[H+W-1] = power(factorial[H+W-1], mod-2) for n in xrange(H+W-2, -1, -1): inverseFactorial[n] = inverseFactorial[n+1] * (n+1) % mod def combi(n, m): return factorial[n] * inverseFactorial[m] * inverseFactorial[n-m] % mod sum = 0 for i in xrange(B+1, W+1): sum = (sum + combi(H-A-1+i-1, i-1) * combi(A-1+W-i, W-i)) % mod print sum
File "/tmp/tmpcrh8hufi/tmp231g7ksp.py", line 25 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s856589410
p04046
u097163034
1577687938
Python
Python (3.4.3)
py
Runtime Error
990
5292
329
import math as m import sys s=input() l1=s.split() h=int(l1[0]) w=int(l1[1]) a=int(l1[2]) b=int(l1[3]) sum1=0 sum2=0 for i in range(a+1,h+1): sum1=0 sum1+=(m.factorial(i+w-b-2))/(m.factorial(i-1)*m.factorial(w-b-1)) sum1*=(m.factorial(h-i+w-b))/(m.factorial(h-i)*m.factorial((w-b))) sum2+=sum1 print(int(sum2))
Traceback (most recent call last): File "/tmp/tmpvdddq5zw/tmpazmfu6zq.py", line 4, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s448258756
p04046
u097163034
1577687891
Python
Python (3.4.3)
py
Runtime Error
28
4340
352
import math as m import sys from tkinter import * s=input() l1=s.split() h=int(l1[0]) w=int(l1[1]) a=int(l1[2]) b=int(l1[3]) sum1=0 sum2=0 for i in range(a+1,h+1): sum1=0 sum1+=(m.factorial(i+w-b-2))/(m.factorial(i-1)*m.factorial(w-b-1)) sum1*=(m.factorial(h-i+w-b))/(m.factorial(h-i)*m.factorial((w-b))) sum2+=sum1 print(int(sum2))
Traceback (most recent call last): File "/tmp/tmpx86r9raw/tmpitm0j56d.py", line 6, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s140873800
p04046
u097163034
1577687807
Python
Python (3.4.3)
py
Runtime Error
988
5276
324
import math as m import sys s=input() l1=s.split() h=int(l1[0]) w=int(l1[1]) a=int(l1[2]) b=int(l1[3]) sum1=0 sum2=0 for i in range(a+1,h+1): sum1=0 sum1+=(m.factorial(i+w-b-2))/(m.factorial(i-1)*m.factorial(w-b-1)) sum1*=(m.factorial(h-i+w-b))/(m.factorial(h-i)*m.factorial((w-b))) sum2+=sum1 print(sum2)
Traceback (most recent call last): File "/tmp/tmp2ogq03_y/tmpij5_jv0y.py", line 4, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s560988805
p04046
u097163034
1577687755
Python
Python (3.4.3)
py
Runtime Error
26
4340
347
import math as m import sys from tkinter import * s=input() l1=s.split() h=int(l1[0]) w=int(l1[1]) a=int(l1[2]) b=int(l1[3]) sum1=0 sum2=0 for i in range(a+1,h+1): sum1=0 sum1+=(m.factorial(i+w-b-2))/(m.factorial(i-1)*m.factorial(w-b-1)) sum1*=(m.factorial(h-i+w-b))/(m.factorial(h-i)*m.factorial((w-b))) sum2+=sum1 print(sum2)
Traceback (most recent call last): File "/tmp/tmpux9mfse6/tmpyfqmmh49.py", line 6, in <module> s=input() ^^^^^^^ EOFError: EOF when reading a line
s179496022
p04046
u327532412
1577313594
Python
Python (3.4.3)
py
Runtime Error
1419
5788
241
import math h, w, a, b = map(int, input().split()) st1 = math.factorial(h+w) / (math.factorial(h) * math.factorial(w)) st2 = math.factorial(a+b) / (math.factorial(a) * math.factorial(b)) total = st1 - st2 wari = 10**9 + 7 print(total % wari)
Traceback (most recent call last): File "/tmp/tmpnpoctvh6/tmp5d_296dd.py", line 2, in <module> h, w, a, b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s899456145
p04046
u892538842
1577100381
Python
Python (3.4.3)
py
Runtime Error
1881
19252
647
h, w, a, b = map(int, input().split(' ')) MOD = 10**9 + 7 MAX = int(1.8*10**5) def modpow(a, b): res = 1 while b: if (b & 1): res = (res * a) % MOD a = (a * a) % MOD b >>= 1 return res def nCr(n, r): if r == 0 or n == r: return 1 return (((f[n] * ivf[n-r]) % MOD) * ivf[r]) % MOD f = [1] * MAX ivf = [0] * MAX for i in range(1, MAX): f[i] = (f[i-1] * i) % MOD ivf[i] = modpow(f[i], MOD-2) r = 0 for i in range(b, w): y1 = h - a - 1 x1 = i y2 = a - 1 x2 = w - i - 1 p = (nCr(x1 + y1, x1) * nCr(x2 + y2, x2)) % MOD r = (r + p) % MOD print(int(r))
Traceback (most recent call last): File "/tmp/tmp4dc0qvoq/tmp13rj8irb.py", line 1, in <module> h, w, a, b = map(int, input().split(' ')) ^^^^^^^ EOFError: EOF when reading a line
s372071832
p04046
u892538842
1577096569
Python
Python (3.4.3)
py
Runtime Error
653
4620
325
import math h, w, a, b = map(int, input().split(' ')) MOD = 10**9 + 7 def ncr(n, r): f = math.factorial return f(n) / f(r) / f(n-r) r = 0 for i in range(b, w): y1 = h - a - 1 x1 = i y2 = a - 1 x2 = w - i - 1 p = (ncr(x1 + y1, x1) * ncr(x2 + y2, x2)) % MOD r = (r + p) % MOD print(int(r))
Traceback (most recent call last): File "/tmp/tmphs0ex9zh/tmp7vxfj5eb.py", line 2, in <module> h, w, a, b = map(int, input().split(' ')) ^^^^^^^ EOFError: EOF when reading a line
s706472964
p04046
u309141201
1576388126
Python
Python (3.4.3)
py
Runtime Error
1620
11028
271
h,w,a,b= map(int,input().split()) mod=10**9+7 f=[1] for i in range(h+w): f.append(f[i]*(i+1)%mod) def comb(n,r,p): return f[n]*pow(f[r],p-2,p)*pow(f[n-r],p-2,p)%p ans=0 for i in range(w-b): ans+=comb(h-a+b-1+i,b+i,mod)*comb(h+a-b-2-i,a-1,mod)%mod print(ans%mod)
Traceback (most recent call last): File "/tmp/tmp90su0mai/tmp84z838um.py", line 1, in <module> h,w,a,b= map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s242719814
p04046
u309141201
1576376129
Python
Python (3.4.3)
py
Runtime Error
1541
15148
637
import numpy as np import math import sys sys.float_info.max H, W, A, B = map(int, input().split()) StoB = np.zeros(B) BtoE = np.zeros(B) sum = 0 # print(StoB) # print(BtoE) all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # print(all) for i in range(B): # print(i) # print(H - A) StoB[i] = math.factorial((i) + (H - A - 1)) / (math.factorial(i) * math.factorial(H - A - 1)) # print(StoB[i]) # print(StoB) BtoE[i] = math.factorial((W - i) + A - 2) / (math.factorial(W - i - 1) * math.factorial(A - 1)) # print(BtoE) sum += StoB[i] * BtoE[i] print(int(all - sum) % (10 ** 9 - 7))
Traceback (most recent call last): File "/tmp/tmpcmhox2qt/tmp_qjlbtmp.py", line 5, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s437969794
p04046
u309141201
1576376101
Python
Python (3.4.3)
py
Runtime Error
1543
21128
637
import numpy as np import math import sys sys.float_info.max H, W, A, B = map(int, input().split()) StoB = np.zeros(B) BtoE = np.zeros(B) sum = 0 # print(StoB) # print(BtoE) all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # print(all) for i in range(B): # print(i) # print(H - A) StoB[i] = math.factorial((i) + (H - A - 1)) / (math.factorial(i) * math.factorial(H - A - 1)) # print(StoB[i]) # print(StoB) BtoE[i] = math.factorial((W - i) + A - 2) / (math.factorial(W - i - 1) * math.factorial(A - 1)) # print(BtoE) sum += StoB[i] * BtoE[i] print(int(all - sum) / (10 ** 9 - 7))
Traceback (most recent call last): File "/tmp/tmptzieia4i/tmplt2w293n.py", line 5, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s601560542
p04046
u309141201
1576375931
Python
Python (3.4.3)
py
Runtime Error
1543
15980
621
import numpy as np import math import sys sys.float_info.max H, W, A, B = map(int, input().split()) StoB = np.zeros(B) BtoE = np.zeros(B) sum = 0 # print(StoB) # print(BtoE) all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # print(all) for i in range(B): # print(i) # print(H - A) StoB[i] = math.factorial((i) + (H - A - 1)) / (math.factorial(i) * math.factorial(H - A - 1)) # print(StoB[i]) # print(StoB) BtoE[i] = math.factorial((W - i) + A - 2) / (math.factorial(W - i - 1) * math.factorial(A - 1)) # print(BtoE) sum += StoB[i] * BtoE[i] print(int(all - sum))
Traceback (most recent call last): File "/tmp/tmp1qconc6b/tmp9io27evi.py", line 5, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s643776801
p04046
u309141201
1576375837
Python
Python (3.4.3)
py
Runtime Error
1544
15144
616
import numpy as np import math import sys sys.float_info.max H, W, A, B = map(int, input().split()) StoB = np.zeros(B) BtoE = np.zeros(B) sum = 0 # print(StoB) # print(BtoE) all = math.factorial(H + W - 2) / (math.factorial(H - 1) * math.factorial(W - 1)) # print(all) for i in range(B): # print(i) # print(H - A) StoB[i] = math.factorial((i) + (H - A - 1)) / (math.factorial(i) * math.factorial(H - A - 1)) # print(StoB[i]) # print(StoB) BtoE[i] = math.factorial((W - i) + A - 2) / (math.factorial(W - i - 1) * math.factorial(A - 1)) # print(BtoE) sum += StoB[i] * BtoE[i] print(all - sum)
Traceback (most recent call last): File "/tmp/tmplc648qx3/tmpx6ypfky8.py", line 5, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s601456353
p04046
u815444398
1575219726
Python
Python (3.4.3)
py
Runtime Error
1400
5728
321
import math h,w,a,b =map(int,input().split()) ans = 0 area1 = b-1 area2 = w+h-b-2 for j in range(h-a): ans1 = math.factorial(area1+j)/(math.factorial(area1)*math.factorial(j)) ans2 = math.factorial(area2-j)/(math.factorial(area2-h+1)*math.factorial(h-1-j)) ans += ans1*ans2 print(int(ans%((10**9)+7)))
Traceback (most recent call last): File "/tmp/tmpli_9lxll/tmphlohczo6.py", line 3, in <module> h,w,a,b =map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s688303376
p04046
u815444398
1575165895
Python
Python (3.4.3)
py
Runtime Error
1397
5792
316
import math h,w,a,b =map(int,input().split()) ans = 0 area1 = b-1 area2 = w+h-b-2 for j in range(h-a): ans1 = math.factorial(area1+j)/(math.factorial(area1)*math.factorial(j)) ans2 = math.factorial(area2-j)/(math.factorial(area2-h+1)*math.factorial(h-1-j)) ans += ans1*ans2 print(ans%((10**9)+7))
Traceback (most recent call last): File "/tmp/tmpscv4mj3b/tmpmid0lkjc.py", line 3, in <module> h,w,a,b =map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s014931963
p04046
u771756419
1574639826
Python
Python (3.4.3)
py
Runtime Error
939
5144
511
nums = input().split() H = int(nums[0]) W = int(nums[1]) A = int(nums[2]) B = int(nums[3]) from math import factorial #全体 total = factorial(H + W -2) / factorial(W-1) / factorial(H - 1) #侵入不可 K = 1 forbidden = 0 while K < B + 1: x1 = factorial(H-A+K-2) / factorial(K-1)/factorial(H-A-1) x2 = factorial(W-K+A-2) / factorial(A-1)/factorial(H-K-1) x = x1 * x2 forbidden += x x = 0 x1 = 0 x2 = 0 K += 1 answer = int(total - forbidden) print(answer % ((10 ** 9) + 7))
Traceback (most recent call last): File "/tmp/tmpmun5ycpn/tmpjyya8vv2.py", line 1, in <module> nums = input().split() ^^^^^^^ EOFError: EOF when reading a line
s925817134
p04046
u771756419
1574639450
Python
Python (3.4.3)
py
Runtime Error
936
5152
472
nums = input().split() H = int(nums[0]) W = int(nums[1]) A = int(nums[2]) B = int(nums[3]) from math import factorial #全体 total = factorial(H + W -2) / factorial(W-1) / factorial(H - 1) #侵入不可 K = 1 forbidden = 0 while K < B + 1: x1 = factorial(H-A+K-2) / factorial(K-1)/factorial(H-A-1) x2 = factorial(W-K+A-2) / factorial(A-1)/factorial(H-K-1) x = x1 * x2 forbidden += x x = 0 x1 = 0 x2 = 0 K += 1 print(total - forbidden)
Traceback (most recent call last): File "/tmp/tmpprreuwov/tmp69xw3auq.py", line 1, in <module> nums = input().split() ^^^^^^^ EOFError: EOF when reading a line
s228866486
p04046
u211025746
1574212547
Python
Python (3.4.3)
py
Runtime Error
229
4092
370
import math HWAB=input().split() H=int(HWAB[0]) W=int(HWAB[1]) A=int(HWAB[2]) B=int(HWAB[3]) temp1=0 temp2=0 goukei=0 for i in range(H-A): temp1=int(math.factorial(i+B-1)/math.factorial(i)/math.factorial(B-1)) temp2=int(math.factorial(W-B-1+H-i-1)/math.factorial(W-B-1)/math.factorial(H-i-1)) goukei+=temp1*temp2 goukei=goukei%1000000007 print(goukei)
Traceback (most recent call last): File "/tmp/tmpzzzojv10/tmpu4k8cag0.py", line 3, in <module> HWAB=input().split() ^^^^^^^ EOFError: EOF when reading a line
s965210467
p04046
u141786930
1574129861
Python
Python (3.4.3)
py
Runtime Error
1446
10924
475
def main(): H, W, A, B = map(int, input().split()) mod = 10**9 + 7 ans = 0 # 予め階乗を計算しておく f = [1] for i in range(H+W-B): f.append(f[i]*(i+1)%mod) # 組み合わせ関数 def comb_mod(n, r, p): return f[n] * pow(f[r], p-2, p) * pow(f[n-r], p-2, p) for i in range(H-A): ans += comb_mod(i+B-1,B-1,mod) * comb_mod(H-1-i+W-B-1,W-B-1,mod) print(ans%mod) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpmjrplb07/tmpr008mak7.py", line 21, in <module> main() File "/tmp/tmpmjrplb07/tmpr008mak7.py", line 2, in main H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s921175709
p04046
u141786930
1574129774
Python
Python (3.4.3)
py
Runtime Error
1445
10900
477
def main(): H, W, A, B = map(int, input().split()) mod = 10**9 + 7 ans = 0 # 予め階乗を計算しておく f = [1] for i in range(H+W-B): f.append(f[i]*(i+1)%mod) # 組み合わせ関数 def comb_mod(n, r, p): return f[n] * pow(f[r], p-2, p) * pow(f[n-r], p-2, p) for i in range(H-A): ans += (comb_mod(i+B-1,B-1,mod) * comb_mod(H-1-i+W-B-1,W-B-1,mod))%mod print(ans) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpw47ryir5/tmp9tk5tfxu.py", line 21, in <module> main() File "/tmp/tmpw47ryir5/tmp9tk5tfxu.py", line 2, in main H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s376659928
p04046
u539517139
1573663100
Python
Python (3.4.3)
py
Runtime Error
18
3064
540
n=200000 def pf(x,y,p): if y==0: return 1 if y%2==0: d=pf(x,y//2,p) return d*d%p if y%2==1: return (x*pf(x,y-1,p))%p facl=[1] for i in range(1,n+2): facl.append(facl[i-1]*i%mod) invl=[1]*(n+2) for i in range(1,n+2): invl[i]=pf(facl[i],mod-2,mod) def comb(x,k): if x<0 or k<0 or x<k: return 0 if x==0 or k==0: return 1 return (facl[x]*invl[k]*invl[x-k])%mod h,w,a,b=map(int,input().split()) mod=10**9+7 if h-a<w-b: h,w=w,h a,b=b,a t=0 for i in range(w-b): t+=comb(h-a+b-1,b+i)*comb(w-b+a-1,a+i) print(t%mod)
Traceback (most recent call last): File "/tmp/tmp35aozxo3/tmp7hoxnue7.py", line 11, in <module> facl.append(facl[i-1]*i%mod) ^^^ NameError: name 'mod' is not defined
s742134924
p04046
u539517139
1573661710
Python
Python (3.4.3)
py
Runtime Error
20
3188
551
def comb(n,k,p): from math import factorial if n<0 or k<0 or n<k: return 0 if n==0 or k==0: return 1 a=factorial(n)%p b=factorial(k)%p c=factorial(n-k)%p return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p def power_func(a,b,p): if b==0: return 1 if b%2==0: d=power_func(a,b//2,p) return d*d %p if b%2==1: return (a*power_func(a,b-1,p))%p h,w,a,b=map(int,input().split()) mod=10**9+7 if h-a<w-b: h,w=w,h a,b=b,a t=0 for i in range(w-b): t+=comb((h-a-i)*(w-b+1+i),w-b+1+i)*comb((w-b-i)*(a+1+i),a+1+i) print(t%mod)
Traceback (most recent call last): File "/tmp/tmpczhsquaw/tmpf8xix0q2.py", line 16, in <module> h,w,a,b=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s953538159
p04046
u021759654
1573265735
Python
Python (3.4.3)
py
Runtime Error
272
27024
611
h,w,a,b = map(int, input().split()) def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod mod = 10**9+7 #出力の制限 N = h+w g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, N + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) #a = cmb(n,r,mod) ans = 0 for i in range(b,w): ans += cmd(h-a-1+i, i, mod) * cmd(a-1+w-i-1, a-1, mod) print(ans%mod)
Traceback (most recent call last): File "/tmp/tmp0hm2yo0n/tmptagngr3l.py", line 1, in <module> h,w,a,b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s267064690
p04046
u021759654
1573263233
Python
Python (3.4.3)
py
Runtime Error
2104
4080
410
from operator import mul from functools import reduce def cmb(n,r): r = min(n-r,r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1,r + 1)) return over // under h, w, a, b = map(int, input().split()) prev_com1 = 0 ans = 0 for i in range(h-a): com1 = cmb(i+b,b) com2 = cmb(h-b+h, h) ans += (com1 - prev_com1)*com2 prev_com1 = com1 print(ans)
Traceback (most recent call last): File "/tmp/tmp1ehgknie/tmp7ef_7byn.py", line 11, in <module> h, w, a, b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s016760980
p04046
u021759654
1573263055
Python
Python (3.4.3)
py
Runtime Error
2104
4072
395
from operator import mul from functools import reduce def cmb(n,r): r = min(n-r,r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1,r + 1)) return over // under h, w, a, b = map(int, input().split()) h-a prev_com1 = 0 ans = 0 for i in range(h-a): com1 = cmb(i+b,b) com2 = cmb(h-b+h, h) ans += (com1 - prev_com1)*com2 print(ans)
Traceback (most recent call last): File "/tmp/tmpmjqcg3tm/tmp4u5i559k.py", line 11, in <module> h, w, a, b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s847609693
p04046
u557494880
1572510882
Python
Python (3.4.3)
py
Runtime Error
17
3064
267
import math H, W, A, B = map(int,input().split()) def f(a,b): p = math.factorial(a+b-2) q = math.factorial(a-1) r = math.factorial(b-1) S = p // (q*r) return S T = 0 for i in range(1,H-A): P = f(i,B+1) Q = f(H-i+1,W-B) T = T + P*Q print(T)
File "/tmp/tmpbvq3jxf3/tmpqcmw3ol_.py", line 8 return S ^^^^^^^^ SyntaxError: 'return' outside function
s536167901
p04046
u149991748
1572465961
Python
Python (3.4.3)
py
Runtime Error
1397
5728
458
# -*-coding: utf-8 -*- import math #マス目と通れないマスの入力 h,w,a,b = map(int,input().split()) ha = h-a total = 0 for i in range(ha): right = b-1 down = i first = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) right = w-b-1 down = h-i-1 last = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) total = total + int(first * last) warizan = int(total%1000000007) print(warizan)
Traceback (most recent call last): File "/tmp/tmphffoqzmz/tmpfpjolj1o.py", line 5, in <module> h,w,a,b = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s492846214
p04046
u149991748
1572382659
Python
Python (3.4.3)
py
Runtime Error
1397
5732
440
# -*-coding: utf-8 -*- import math #マス目と通れないマスの入力 h,w,a,b = map(int,input().split()) ha = h-a total = 0 for i in range(ha): right = b-1 down = i first = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) right = w-b-1 down = h-i-1 last = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) total = total + int(first * last) print(int(total%1000000007))
Traceback (most recent call last): File "/tmp/tmpns3ntgpq/tmpzexeo2ef.py", line 5, in <module> h,w,a,b = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s686889419
p04046
u149991748
1572382570
Python
Python (3.4.3)
py
Runtime Error
1391
5820
563
# -*-coding: utf-8 -*- import math #マス目と通れないマスの入力 h,w,a,b = map(int,input().split()) ha = h-a total = 0 for i in range(ha): right = b-1 down = i first = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) right = w-b-1 down = h-i-1 print("right:"+str(right)+"down:"+str(down)) last = math.factorial(right+down) / (math.factorial(right)*math.factorial(down)) print("first:"+str(first)+"last:"+str(last)) total = total + int(first * last) print("total:"+str(total)) print(int(total%1000000007))
Traceback (most recent call last): File "/tmp/tmpj77cwzsx/tmplz2b_q7n.py", line 5, in <module> h,w,a,b = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s887589847
p04046
u079427319
1571811386
Python
Python (3.4.3)
py
Runtime Error
2104
3940
309
height, width, disabledHeight, disabledWidth = map(int, input().split()) def getPattern(x, y): if (x <= disabledWidth) and (y > height - disabledHeight): return 0 if (x == 1) or (y == 1): return 1 return getPattern(x-1, y) + getPattern(x, y-1) print(getPattern(width, height) % (pow(10, 9) + 7))
Traceback (most recent call last): File "/tmp/tmpb0y0_ev4/tmpb_he0wtm.py", line 1, in <module> height, width, disabledHeight, disabledWidth = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s055718564
p04046
u079427319
1571811141
Python
Python (3.4.3)
py
Runtime Error
2104
3936
291
height, width, disabledHeight, disabledWidth = map(int, input().split()) def getPattern(x, y): if (x <= disabledWidth) and (y > height - disabledHeight): return 0 if (x == 1) or (y == 1): return 1 return getPattern(x-1, y) + getPattern(x, y-1) print(getPattern(width, height))
Traceback (most recent call last): File "/tmp/tmpxq88tjwg/tmpzm13zx59.py", line 1, in <module> height, width, disabledHeight, disabledWidth = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s086637085
p04046
u079427319
1571810956
Python
Python (3.4.3)
py
Runtime Error
17
3060
290
height, width, disabledHeight, disabledWidth = map(int, input().spilit()) def getPattern(x, y): if (x == 1) or (y == 1): return 1 if (x <= disabledWidth) or (y > height - disabledHeight): return 0 return getPattern(x-1, y) + getPattern(x, y-1) print(getPattern(width, height))
Traceback (most recent call last): File "/tmp/tmpyt14jgdc/tmpbezl5aa6.py", line 1, in <module> height, width, disabledHeight, disabledWidth = map(int, input().spilit()) ^^^^^^^ EOFError: EOF when reading a line
s936004910
p04046
u912115033
1571756085
Python
Python (3.4.3)
py
Runtime Error
87
12588
788
h, w, a, b = map(int, input().split()) mod = 1000000007 stairs = [1] for i in range(1, h+w+1): stairs.append(stairs[i-1]*i%mod) inverse_stairs = [0]*(h+w) inverse_stairs[h+w-1] = modpow(stairs[h+w-1], mod-2) for i in range(h+w-2, -1, -1): inverse_stairs[i] = inverse_stairs[i+1] * (i+1) % mod def modpow(x, y): if y == 0 : return 1 elif y == 1 : return x % mod elif y % 2 == 0 : return modpow(x, y//2)**2 % mod else : return modpow(x, y//2)**2 * x % mod ret = 0 for i in range(w-b): com = stairs[w-i+h-a-2]%mod com = com*inverse_stairs[w-i-1]%mod com = com*inverse_stairs[h-a-1]%mod com = com*stairs[i+a-1]%mod com = com*inverse_stairs[i]%mod com = com*inverse_stairs[a-1]%mod ret += com print(ret%mod)
Traceback (most recent call last): File "/tmp/tmpdnx53gyg/tmp54be7qjx.py", line 1, in <module> h, w, a, b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s004536274
p04046
u606878291
1570508646
Python
Python (3.4.3)
py
Runtime Error
2104
7264
751
import fractions import math MOD = math.pow(10, 9) + 7 def calc_routes(dx, dy): if dx == 0 or dy == 0: return 1 else: return int(fractions.Fraction( math.factorial(dx + dy), math.factorial(dx) * math.factorial(dy) )) def check(h, w, a, b): p = (b + 1, h - a) all_routes = 0 while p[0] <= w and p[1] > 0: d1 = (p[0] - 1, p[1] - 1) d2 = (w - p[0], h - p[1]) r1 = calc_routes(*d1) r2 = calc_routes(*d2) routes = r1 * r2 all_routes += routes p = (p[0] + 1, p[1] - 1) return int(all_routes % MOD) def main(): h, w, a, b = map(int, input().split()) print(check(h, w, a, b)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmps9jf06p1/tmpz9sg4jvd.py", line 37, in <module> main() File "/tmp/tmps9jf06p1/tmpz9sg4jvd.py", line 32, in main h, w, a, b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s376865170
p04046
u606878291
1570385794
Python
Python (3.4.3)
py
Runtime Error
2104
5716
405
import math MOD = math.pow(10, 9) + 7 def check(h, w, a, b): c, d = h - a, w - b start2p = math.factorial(a + b) // (math.factorial(a) * math.factorial(b)) p2end = math.factorial(c + b) // (math.factorial(c) * math.factorial(d)) return (start2p * p2end) % MOD def main(): h, w, a, b = map(int, input().split()) print(check(h, w, a, b)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpms5ygyvj/tmpnk66z6ao.py", line 19, in <module> main() File "/tmp/tmpms5ygyvj/tmpnk66z6ao.py", line 14, in main h, w, a, b = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s966576965
p04046
u606878291
1570385744
Python
Python (3.4.3)
py
Runtime Error
19
3064
403
import math MOD = math.pow(10, 9) + 7 def check(h, w, a, b): c, d = h - a, w - b start2p = math.factorial(a + b) // (math.factorial(a) * math.factorial(b)) p2end = math.factorial(c + b) // (math.factorial(c) * math.factorial(d)) return (start2p * p2end) % MOD def main(): h, w, a, b = map(int, input.split()) print(check(h, w, a, b)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpna4vmgmy/tmp42helzhn.py", line 19, in <module> main() File "/tmp/tmpna4vmgmy/tmp42helzhn.py", line 14, in main h, w, a, b = map(int, input.split()) ^^^^^^^^^^^ AttributeError: 'builtin_function_or_method' object has no attribute 'split'
s067206608
p04046
u606878291
1570385701
Python
Python (3.4.3)
py
Runtime Error
18
3060
401
import math MOD = math.pow(10, 9) + 7 def check(h, w, a, b): c, d = h - a, w - b start2p = math.factorial(a + b) // math.factorial(a) // math.factorial(b) p2end = math.factorial(c + b) // math.factorial(c) // math.factorial(d) return (start2p * p2end) % MOD def main(): h, w, a, b = map(int, input.split()) print(check(h, w, a, b)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpw0f6x3nf/tmp3w4ec9e3.py", line 19, in <module> main() File "/tmp/tmpw0f6x3nf/tmp3w4ec9e3.py", line 14, in main h, w, a, b = map(int, input.split()) ^^^^^^^^^^^ AttributeError: 'builtin_function_or_method' object has no attribute 'split'
s063431401
p04046
u606878291
1570385624
Python
Python (3.4.3)
py
Runtime Error
17
3060
405
import math MOD = math.pow(10, 9) + 7 def check(h, w, a, b): c, d = h - a, w - b start2p = math.factorial(a + b) // (math.factorial(a) // math.factorial(b)) p2end = math.factorial(c + b) // (math.factorial(c) // math.factorial(d)) return (start2p * p2end) % MOD def main(): h, w, a, b = map(int, input.split()) print(check(h, w, a, b)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpc6gk682a/tmpv7ujergg.py", line 19, in <module> main() File "/tmp/tmpc6gk682a/tmpv7ujergg.py", line 14, in main h, w, a, b = map(int, input.split()) ^^^^^^^^^^^ AttributeError: 'builtin_function_or_method' object has no attribute 'split'
s395031511
p04046
u780962115
1569465652
Python
Python (3.4.3)
py
Runtime Error
19
3188
196
from math import gamma cnt=0 h,w,a,b=map(int,input().split()) for k in range(0,h-a): cnt+= (int((gamma(b+k)*gamma(h+w-k-b-1))/(gamma(k+1)*gamma(b)*gamma(w-b)*gamma(h-k))))//(10^9+7) print(cnt)
Traceback (most recent call last): File "/tmp/tmp6s3j5eim/tmp1iq61sc6.py", line 3, in <module> h,w,a,b=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s239974360
p04046
u708255304
1569300398
Python
PyPy3 (2.4.0)
py
Runtime Error
2699
1533960
1034
class Queue: def __init__(self, data=[]): self.data = data def enqueue(self, x): self.data.append(x) def dequeue(self): return self.data.pop(0) def is_Empty(self): if len(self.data) == 0: return True else: return False mod = 1000000007 H, W, A, B = map(int, input().split()) # 縦H, 横W, 下からA左からBは入れない counter = [[0]*W for _ in range(H)] flag = [[False]*W for _ in range(H)] counter[0][0] = 1 q = Queue() q.enqueue((0, 0)) adjacents = [(0, 1), (1, 0)] while not q.is_Empty(): cy, cx = q.dequeue() for dy, dx in adjacents: if cy+dy >= H or cy+dy < 0 or cx+dx >= W or cx+dx < 0 or (cy+dy >= (H-A) and B > cx+dx): continue counter[cy+dy][cx+dx] += counter[cy][cx] if not flag[cy+dy][cx+dx]: q.enqueue((cy+dy, cx+dx)) flag[cy+dy][cx+dx] = True if counter[1][2] == 5: print(counter) exit() print(counter[-1][-1] % mod) # print(counter)
Traceback (most recent call last): File "/tmp/tmp5byo3522/tmpwi066oa1.py", line 19, in <module> H, W, A, B = map(int, input().split()) # 縦H, 横W, 下からA左からBは入れない ^^^^^^^ EOFError: EOF when reading a line
s863461232
p04046
u723590269
1569291758
Python
Python (3.4.3)
py
Runtime Error
2104
17284
1046
h,w,a,b =map(int,input().split()) mod = 10**9+7 nfact_l = [1 for i in range(h+w+1)] def nfact_mod(n0,mod0): for i in range(1,len(nfact_l)): nfact_l[i] *= (nfact_l[i-1]*i)%mod nfact_mod(h+w+1,mod) #二分累乗法 あとで使う def powfunc_mod(n0,r0,mod0): ans0 = 1 r0 = bin(r0)[:1:-1] for i in r0: if i == "1": ans0 *= (n0 % mod0) n0 *= (n0 % mod0) ans0 %= mod0 return ans0 nfact_inv_l = [1 for i in range(h+w+1)] for i in range(len(nfact_inv_l)): nfact_inv_l[i] = powfunc_mod(nfact_l[i],mod-2,mod) point1 = [0 for i in range(w-b)] for i in range(len(point1)): # ... = n!*r!^(p-2)*(n-r)!^(p-2) [mod] yoko = b+i tate = h-a-1 n = yoko+tate r = tate point1[i] = (nfact_l[n]*nfact_inv_l[r]*nfact_inv_l[n-r])%mod #point1から目的まで行く経路数 out = 0 for i in range(len(point1)): yoko = w-b-1+i tate = a-1 n = yoko+tate r = tate out += ((((point1[i]*nfact_l[n])%mod)*nfact_inv_l[r]%mod)*nfact_inv_l[n-r])%mod print(out)
Traceback (most recent call last): File "/tmp/tmp_cpm_bsz/tmpgdt6c3ix.py", line 1, in <module> h,w,a,b =map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s649695695
p04046
u708255304
1568754121
Python
Python (3.4.3)
py
Runtime Error
2220
1931124
1034
class Queue: def __init__(self, data=[]): self.data = data def enqueue(self, x): self.data.append(x) def dequeue(self): return self.data.pop(0) def is_Empty(self): if len(self.data) == 0: return True else: return False mod = 1000000007 H, W, A, B = map(int, input().split()) # 縦H, 横W, 下からA左からBは入れない counter = [[0]*W for _ in range(H)] flag = [[False]*W for _ in range(H)] counter[0][0] = 1 q = Queue() q.enqueue((0, 0)) adjacents = [(0, 1), (1, 0)] while not q.is_Empty(): cy, cx = q.dequeue() for dy, dx in adjacents: if cy+dy >= H or cy+dy < 0 or cx+dx >= W or cx+dx < 0 or (cy+dy >= (H-A) and B > cx+dx): continue counter[cy+dy][cx+dx] += counter[cy][cx] if not flag[cy+dy][cx+dx]: q.enqueue((cy+dy, cx+dx)) flag[cy+dy][cx+dx] = True if counter[1][2] == 5: print(counter) exit() print(counter[-1][-1] % mod) # print(counter)
Traceback (most recent call last): File "/tmp/tmpaif1r40w/tmpe_mr4kko.py", line 19, in <module> H, W, A, B = map(int, input().split()) # 縦H, 横W, 下からA左からBは入れない ^^^^^^^ EOFError: EOF when reading a line
s993977273
p04046
u266874640
1568575135
Python
Python (3.4.3)
py
Runtime Error
2104
5388
314
import math H, W, A, B = map(int,input().split()) ans = 0 MOD = 10**9+7 for i in range(H-A): first = (math.factorial(B-1+i)/(math.factorial(B-1)*math.factorial(i))) % MOD last = (math.factorial(W+H-B-i-2)%MOD/(math.factorial(W-B-1)*math.factorial(H-i-1))) % MOD ans += int(first*last) print(ans % MOD)
Traceback (most recent call last): File "/tmp/tmpico0q8u7/tmpmjitm_ki.py", line 2, in <module> H, W, A, B = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s867515855
p04046
u469254913
1568168190
Python
Python (3.4.3)
py
Runtime Error
94
11028
306
H,W,A,B = map(int,input().split()) mod = 10**9 + 7 f = [1] for i in range(H+W): f.append(f[i]*(i+1)%mod) def comb(A,B,mod): return f[A] * pow(f[B],mod-2,mod) * pow(f[a-b],mod-2,mod) % mod res = 0 for i in range(B,W): res += comb(H-A+i-1,i,mod) * comb(A+W-i-2,A-1,mod) % mod print(res%mod)
Traceback (most recent call last): File "/tmp/tmp8g_tfliy/tmp9ryo49e4.py", line 1, in <module> H,W,A,B = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s729234961
p04046
u378328623
1567622920
Python
Python (3.4.3)
py
Runtime Error
2110
341584
500
import numpy as np H, W, A, B = map(int, input().split()) p = int(10e9+7) D = np.zeros((H,W), dtype=int) D[(H-A):, :B] = -1 D[0,0] = 1 u = 0 l = 0 for i in range(H): for j in range(W): if D[i,j] == 0: if i == 0: u = 0 else: u = D[i-1,j] if D[i,j-1] == -1: l = 0 elif j == 0: l = 0 else: l = D[i,j-1] D[i,j] = (u+l)%p print(D[H-1,W-1])
Traceback (most recent call last): File "/tmp/tmpb63uagob/tmp20qwcepo.py", line 2, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s456311832
p04046
u270144704
1567546829
Python
Python (3.4.3)
py
Runtime Error
2104
3492
315
CONST=10**9+7 H,W,A,B=map(int,input().split()) def kaizyo(num): multi=1 for i in range(1,num+1): multi*=i return multi sum=0 for i in range(0,W-B): sum+=(kaizyo(H-A-1+B+i)/(kaizyo(H-A-1)*kaizyo(B+i))%CONST)*(kaizyo(A-1+W-B-1-i)/(kaizyo(A-1)*kaizyo(W-B-1-i))%CONST) print(int(sum%CONST))
Traceback (most recent call last): File "/tmp/tmpopzsckfi/tmppbc34rnc.py", line 2, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s565017487
p04046
u270144704
1567277204
Python
Python (3.4.3)
py
Runtime Error
2104
3488
293
H,W,A,B=map(int,input().split()) def kaizyo(num): multi=1 for i in range(1,num+1): multi*=i return multi sum=0 for i in range(0,W-B): sum+=(kaizyo(H-A-1+B+i)/(kaizyo(H-A-1)*kaizyo(B+i)))*(kaizyo(A-1+W-B-1-i)/(kaizyo(A-1)*kaizyo(W-B-1-i))) print(int(sum%(10**9+7)))
Traceback (most recent call last): File "/tmp/tmpzdjmrv6u/tmpwcqhiu3b.py", line 1, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s868581199
p04046
u654470292
1567167323
Python
PyPy3 (2.4.0)
py
Runtime Error
2110
107612
376
import sys import math def input(): return sys.stdin.readline()[:-1] h,w,a,b=map(int,input().split()) mod=10**9+7 def c_c(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) ans=c_c(h+w-2,w-1) for i in range(a): ans-=c_c(h-a+b-1,h-a+i)*c_c(a+w-b-1,a-i-1) # print(c_c(h-a+b-1,h-a+i)) # print(c_c(a+w-b-1,a-i-1)) print(ans%mod)
Traceback (most recent call last): File "/tmp/tmpmb7b10c0/tmp2g6hxraq.py", line 6, in <module> h,w,a,b=map(int,input().split()) ^^^^^^^ ValueError: not enough values to unpack (expected 4, got 0)
s713361936
p04046
u227082700
1565644559
Python
Python (3.4.3)
py
Runtime Error
17
2940
228
h,w,a,b=map(int,input().split())m=10**9+7;f=[1] for i in range(h+w):f+=[f[-1]*(i+1)%m] def comb(a,b,m):return f[a]*pow(f[b],m-2,m)*pow(f[a-b],m-2,m)%m x=0 for i in range(b,w):x+=comb(h-a+i-1,i,m)*comb(a+w-i-2,a-1,m)%m print(x%m)
File "/tmp/tmp_xjxauzl/tmp6vsg4ivt.py", line 1 h,w,a,b=map(int,input().split())m=10**9+7;f=[1] ^ SyntaxError: invalid syntax
s158955275
p04046
u084324798
1565153121
Python
Python (3.4.3)
py
Runtime Error
18
3064
845
def nCr(n, r): return ((((fact[n]*finv[n-r])%mod)*finv[r])%mod) def powmod(a, n, m): if n == 0: return 1 elif n == 1: return (a % m) elif n%2 == 0: s = powmod(a, int(n/2), m) temp = (s * s) % m return temp else: s = powmod(a, int(n/2), m) temp = ((s * s) * a) % m return temp mod = 10**9 + 7 inv = mod - 2 maxn = high + width - 2 fact = [0] * (maxn+1) finv = [0] * (maxn+1) fact[0] = fact[1] = 1 finv[0] = finv[1] = 1 # 階乗を求める for i in range(2, maxn+1): fact[i] = (fact[i-1] * i) % mod # 階乗の逆元を求める for i in range(2, maxn+1): finv[i] = powmod(fact[i], inv, mod) route = 0 for i in range(1, high-y+1): route += (nCr(x+i-2, i-1) * nCr(width+high-x-1-i, high-i)) % mod route = route % mod print(int(route))
Traceback (most recent call last): File "/tmp/tmp0lbao8dy/tmp054w1_ie.py", line 20, in <module> maxn = high + width - 2 ^^^^ NameError: name 'high' is not defined
s900339276
p04046
u084324798
1565151651
Python
Python (3.4.3)
py
Runtime Error
151
13412
853
high, width, y, x = map(int, input().split()) def nCr(n, r): return ((((fact[n]*finv[n-r])%mod)*finv[r])%mod) def powmod(a, n, m): if n == 0: return 1 elif n == 1: return a if n%2 == 0: temp = (powmod(a, n/2, m) ** 2) % m return temp else: temp = (((powmod(a, n/2, m) ** 2) % m) * a) % m return temp mod = 10**9 + 7 inv = mod - 2 maxn = high + width - 2 fact = [0] * (maxn+1) finv = [0] * (maxn+1) fact[0] = fact[1] = 1 finv[0] = finv[1] = 1 # 階乗を求める for i in range(2, maxn+1): fact[i] = (fact[i-1] * i) % mod # 階乗の逆元を求める for i in range(2, maxn+1): finv[i] = powmod(fact[i], inv, mod) route = 0 for i in range(1, high-y+1): route += (nCr(x+i-2, i-1) * nCr(width+high-x-1-i, high-i)) % mod route = route % mod print(int(route))
Traceback (most recent call last): File "/tmp/tmpcx3yxuyr/tmparg64xk2.py", line 1, in <module> high, width, y, x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s880295885
p04046
u084324798
1565063414
Python
Python (3.4.3)
py
Runtime Error
1398
5768
526
high, width, y, x = map(int, input().split()) import math route = 0 for i in range(1,high-y+1): if i != high-y: route += ((math.factorial(x+i-1)/(math.factorial(x)*math.factorial(i-1)))%(10**9+7))*((math.factorial(width-x-2+high-i)/(math.factorial(width-x-2)*math.factorial(high-i))))%(10**9+7) else: route += ((math.factorial(x+i-1)/(math.factorial(x)*math.factorial(i-1)))%(10**9+7))*((math.factorial(width-x-1+high-i)/(math.factorial(width-x-1)*math.factorial(high-i))))%(10**9+7) print(int(route))
Traceback (most recent call last): File "/tmp/tmpawruy8fw/tmpkks3m98q.py", line 1, in <module> high, width, y, x = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s807383653
p04046
u999669171
1565059814
Python
Python (3.4.3)
py
Runtime Error
74
4464
389
nCr = {} def cmb(n, r): if r == 0 or r == n: return 1 if r == 1: return n if (n,r) in nCr: return nCr[(n,r)] nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1) return nCr[(n,r)] h, w, a, b = map( int, input().split() ) ans = 0 mod_parent = 10**9 + 7 for i in range( 1, w-b ) : ans += ( cmb( h-a-1+i, i ) % mod_parent ) + ( cmb( a+w-i-2, a-1 ) % mod_parent ) print( ans )
Traceback (most recent call last): File "/tmp/tmph6jsfswy/tmpv0loed0m.py", line 10, in <module> h, w, a, b = map( int, input().split() ) ^^^^^^^ EOFError: EOF when reading a line
s901816297
p04046
u999669171
1565057588
Python
Python (3.4.3)
py
Runtime Error
86
5156
382
nCr = {} def cmb(n, r): if r == 0 or r == n: return 1 if r == 1: return n if (n,r) in nCr: return nCr[(n,r)] nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1) return nCr[(n,r)] h, w, a, b = map( int, input().split() ) ans = 0 mod_parent = 10**9 + 7 for i in range( a+1 ) : ans += ( cmb( b+h-a, i ) % mod_parent ) + ( cmb( h+w-b, h-i ) % mod_parent ) print( ans )
Traceback (most recent call last): File "/tmp/tmptoy7y01f/tmptkivkkyu.py", line 10, in <module> h, w, a, b = map( int, input().split() ) ^^^^^^^ EOFError: EOF when reading a line
s834792252
p04046
u457554982
1564963929
Python
Python (3.4.3)
py
Runtime Error
2104
6296
314
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-2,h-1,w-1,a+b-2,a-1,b-1] list2=[] list3=[] import math for i in range(6): list2.append(int(math.factorial(list1[i]))) way1=int(list2[0]/(list2[1]*list2[2])) way2=int(list2[3]/(list2[4]*list2[5])) allways=way1-way2 answer=int(allways%1000000007) print(answer)
Traceback (most recent call last): File "/tmp/tmpgzk7xd0d/tmpulio07c9.py", line 1, in <module> h,w,a,b=[int(s) for s in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s436885289
p04046
u457554982
1564963597
Python
Python (3.4.3)
py
Runtime Error
17
3064
298
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-2,h-1,w-1,a+b-2,a-1,b-1] list2=[] list3=[] import math for i in range(6): list2.append(math.factorial(list[i])) way1=list2[0]/(list2[1]*list2[2]) way2=list2[3]/(list2[4]*list2[5]) allways=way1-way2 answer=int(allways%1000000007) print(answer)
Traceback (most recent call last): File "/tmp/tmpzo99gy49/tmpmdp0xu5t.py", line 1, in <module> h,w,a,b=[int(s) for s in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s301479046
p04046
u457554982
1564962624
Python
Python (3.4.3)
py
Runtime Error
2104
3524
577
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-1,h,w,a+b-1,a,b] list2=[] list3=[] for i in range(0,4,3): kaijo1=1 kaijo2=1 for j in range (list1[i+1],list1[i]): kaijo1=kaijo1*j for k in range(1,list1[i+2]): kaijo2=kaijo2*k list2.extend([kaijo1,kaijo2]) allways=(list2[0]/list2[1])-(list2[2]/list2[3]) """ for i in range(6): kaijo=1 for j in range(1,list1[i]): kaijo=kaijo*j list2.append(kaijo) for i in range(0,4,3): ways=list2[i]/(list2[i+1]*list2[i+2]) list3.append(ways) allways=list3[0]-list3[1] """ answer=int(allways%1000000007) print(answer)
Traceback (most recent call last): File "/tmp/tmpt0ned2a6/tmpmvogwy6v.py", line 1, in <module> h,w,a,b=[int(s) for s in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s713811245
p04046
u457554982
1564959094
Python
Python (3.4.3)
py
Runtime Error
2103
3504
336
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-1,h,w,a+b-1,a,b] list2=[] list3=[] for i in range(6): kaijo=1 for j in range(1,list1[i]): kaijo=kaijo*j list2.append(kaijo) for i in range(0,4,3): ways=list2[i]/(list2[i+1]*list2[i+2]) list3.append(ways) allways=list3[0]-list3[1] answer=int(allways%1000000007) print(answer)
Traceback (most recent call last): File "/tmp/tmp8b_m3o1l/tmpd4e2wtd4.py", line 1, in <module> h,w,a,b=[int(s) for s in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s706151819
p04046
u457554982
1564958959
Python
Python (3.4.3)
py
Runtime Error
2104
3500
331
h,w,a,b=[int(s) for s in input().split()] list1=[h+w-1,h,w,a+b-1,a,b] list2=[] list3=[] for i in range(6): kaijo=1 for j in range(1,list1[i]): kaijo=kaijo*j list2.append(kaijo) for i in range(0,4,3): ways=list2[i]/(list2[i+1]*list2[i+2]) list3.append(ways) allways=list3[0]-list3[1] answer=allways%1000000007 print(answer)
Traceback (most recent call last): File "/tmp/tmpv4bykjsh/tmp311iuw4n.py", line 1, in <module> h,w,a,b=[int(s) for s in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s609565863
p04046
u159723084
1564183587
Python
Python (3.4.3)
py
Runtime Error
2112
14792
499
# -*- coding: utf-8 -*- """ Created on Fri Jul 26 05:23:03 2019 @author: matsui """ import numpy as np def kai(a,b): ans=int(1) for i in range(a,b-1,-1): ans*=int(i) return int(ans) def C(a,b): #x=np.arange(b+1,a+1) #y=np.arange(1,(a-b)+1) ans = kai(a,(b+1))/kai((a-b),1) return int(ans%(1e9+7)) H,W,A,B=map(int,input().split()) ans=0 for i in range(H-A): ans+=C((B-1+i),i)*C(((W-B-1)+(H-i-1)),(H-i-1)) ans=int(ans%(1e9+7)) print(ans)
Traceback (most recent call last): File "/tmp/tmp_8ehkxf_/tmp2wzk6x_3.py", line 23, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s464500500
p04046
u159723084
1564182484
Python
Python (3.4.3)
py
Runtime Error
2104
3516
383
# -*- coding: utf-8 -*- """ Created on Fri Jul 26 05:23:03 2019 @author: matsui """ def kai(a,b): ans=1 for i in range(a,b-1,-1): ans*=i return ans def C(a,b): return kai(a,(b+1))/kai((a-b),1) H,W,A,B=map(int,input().split()) ans=0 for i in range(H-A): ans+=C((B-1+i),i)*C(((W-B-1)+(H-i-1)),(H-i-1)) ans=int(ans%(1e9+7)) print(ans)
Traceback (most recent call last): File "/tmp/tmpl5m_xakz/tmphkl58n2e.py", line 18, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s826989171
p04046
u159723084
1564182143
Python
Python (3.4.3)
py
Runtime Error
2108
3508
378
# -*- coding: utf-8 -*- """ Created on Fri Jul 26 05:23:03 2019 @author: matsui """ def kai(a,b): ans=1 for i in range(a,b-1,-1): ans*=i return ans def C(a,b): return kai(a,(b+1))/kai((a-b),1) H,W,A,B=map(int,input().split()) ans=0 for i in range(H-A): ans+=C((B-1+i),i)*C(((W-B-1)+(H-i-1)),(H-i-1)) ans=ans%(1e9+7) print(ans)
Traceback (most recent call last): File "/tmp/tmpdzpoh4wi/tmpb2dv4s28.py", line 18, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s007796222
p04046
u334260611
1561844096
Python
Python (3.4.3)
py
Runtime Error
218
15708
1034
from operator import mul from functools import reduce def cmb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2,r+1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p-1,r,p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result H, W, A, B = list(map(int, input().split(' '))) print(H, W, A, B) n1 = B - 1 r1 = B - 1 n2 = W - B - 1 + H - 1 r2 = W - B - 1 route1 = cmb(n1, r1) route2 = cmb(n2, r2) route = route1 * route2 for i in range(1, H - A): k1 = (n1 + 1) / (n1 + 1 - r1) k2 = (n2 - r2) / n2 route1 *= k1 route2 *= k2 n1 += 1 n2 -= 1 route += route1 * route2 #print(i, k1, k2) print(int(route) % (10 ** 9 + 7))
Traceback (most recent call last): File "/tmp/tmppq1h3156/tmp6p9wiwca.py", line 27, in <module> H, W, A, B = list(map(int, input().split(' '))) ^^^^^^^ EOFError: EOF when reading a line
s304463816
p04046
u167751176
1561249569
Python
Python (3.4.3)
py
Runtime Error
17
3064
603
def main(): H, W, A, B = map(int, input().split()) H, W= H-1, W-1 DIV = 10**9+7 size = H+W+1 fact = [0]*size inverse = [0]*size inv_cal = [0]*size fact[:2] = [1, 1] inverse[:2] = [1, 1] inv_cal[:2] = [0, 1] for i in range(2, size): fact[i] = (fact[i-1]*i%DIV) inv_cal[i] = (-inv_cal[DIV%i]*(DIV//i))%DIV inverse[i] = inverse[i-1]*inv_cal[i]%DIV def C(n, r): ans = fact[n]*inverse[r]%DIV return ans*inverse[n-r]%DIV ans = 0 for x in range(B, W+1): y = H-A tmp = (C(x+y, x)*(C(H+W-x-y-1, W-x))%DIV ans += tmp ans %= DIV print(ans) if __name__ == '__main__': main()
File "/tmp/tmpm15bveaz/tmphnvw2m_i.py", line 26 tmp = (C(x+y, x)*(C(H+W-x-y-1, W-x))%DIV ^ SyntaxError: '(' was never closed
s493540222
p04046
u167751176
1561249409
Python
Python (3.4.3)
py
Runtime Error
308
25588
616
def main(): H, W, A, B = map(int, input().split()) H, W= H-1, W-1 DIV = 10**9+7 fact = [0]*(H+W-A+1) inverse = [0]*(H+W-A+1) inv_cal = [0]*(H+W-A+1) fact[:2] = [1, 1] inverse[:2] = [1, 1] inv_cal[:2] = [0, 1] for i in range(2, H+W-A+1): fact[i] = (fact[i-1]*i%DIV) inv_cal[i] = (-inv_cal[DIV%i]*(DIV//i))%DIV inverse[i] = inverse[i-1]*inv_cal[i]%DIV def C(n, r): ans = fact[n]*inverse[r]%DIV return ans*inverse[n-r]%DIV ans = 0 for x in range(B, W+1): y = H-A tmp = (C(x+y, x)%DIV)*(C(H+W-x-y-1, W-x)%DIV)%DIV ans += tmp ans %= DIV print(ans) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpdl_1gc4w/tmpbuyb2s5m.py", line 33, in <module> main() File "/tmp/tmpdl_1gc4w/tmpbuyb2s5m.py", line 2, in main H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s078418811
p04046
u648452607
1560893035
Python
Python (3.4.3)
py
Runtime Error
2108
6832
364
[h,w,a,b]=[int(_) for _ in input().split()] import math import functools import operator def p(x,y): if x==0 or y==0: return 0 elif x==1 or y==1: return 1 if x>=y: k=x-1 l=y-1 else: k=y-1 l=x-1 return functools.reduce(operator.mul, [(k-i)/(l-i) for i in range(l)]) n=sum([p(i+1,b)*p(h-i,w-b) for i in range(h-a)])/(10**9)+7 print(int(n))
Traceback (most recent call last): File "/tmp/tmpkgsmx1_2/tmplyhna06f.py", line 1, in <module> [h,w,a,b]=[int(_) for _ in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s159977058
p04046
u648452607
1560883052
Python
Python (3.4.3)
py
Runtime Error
927
5144
275
[h,w,a,b]=[int(_) for _ in input().split()] import math def p(x,y): if x==0 or y==0: a=0 elif x==1 or y==1: a=1 else: a=math.factorial(x+y-2)/math.factorial(x-1)/math.factorial(y-1) return a n=0 for i in range(h-a): n+=p(i+1,b)*p(h-i,w-b) n%=(10**9)+7 print(int(n))
Traceback (most recent call last): File "/tmp/tmpiddy7lhu/tmpfsvzkrce.py", line 1, in <module> [h,w,a,b]=[int(_) for _ in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s610146808
p04046
u745561510
1560488162
Python
Python (3.4.3)
py
Runtime Error
17
3064
652
X, Y, Z, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A = sorted(A, key = lambda x:-x) B = sorted(B, key = lambda x:-x) C = sorted(C, key = lambda x:-x) AB = [0] * (X * Y) index = 0 for i in range(len(A)): for j in range(len(B)): AB[index] = A[i] + B[j] index += 1 AB = sorted(AB, key = lambda x:-x) ABC = [0] * min(3050, X * Y * Z) index = 0 for i in AB: if index >= 3000: break for j in C: ABC[index] = i + j index += 1 ABC = sorted(ABC, key = lambda x:-x) for i in range(0,K): print(ABC[i])
Traceback (most recent call last): File "/tmp/tmpxk2287xu/tmpu1yjp223.py", line 1, in <module> X, Y, Z, K = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s871402893
p04046
u756518877
1558299131
Python
Python (3.4.3)
py
Runtime Error
2104
3520
475
# -*- coding: utf-8 -*- #入力 h,w,a,b=map(int,input().split(" ")) count=0 #階乗の関数を定義 def kaizyou(a): ans=a if a==1 or a==0: ans=1 else: for i in range(1,a): ans=ans*(a-i) return int(ans) for i in range(1,h-a+1): count1=kaizyou(b-1+i-1)/(kaizyou(b-1)*kaizyou(i-1)) count2=kaizyou(w-b-1+h-i)/(kaizyou(w-b-1)*kaizyou(h-i)) count=count+count1*count2 count=count%(1000000000+7) count=int(count) print(count)
Traceback (most recent call last): File "/tmp/tmplv2ueug5/tmpb1uaz3ak.py", line 3, in <module> h,w,a,b=map(int,input().split(" ")) ^^^^^^^ EOFError: EOF when reading a line
s121222389
p04046
u756518877
1558298365
Python
Python (3.4.3)
py
Runtime Error
718
5148
332
# -*- coding: utf-8 -*- import math #入力 h,w,a,b=map(int,input().split(" ")) count=0 for i in range(1,h-a+1): count=count+math.factorial(b-1+i-1)/(math.factorial(b-1)*math.factorial(i-1))*\ math.factorial(w-b-1+h-i)/(math.factorial(int(w-b-1))*math.factorial(h-i)) count=count%(1000000000+7) count=int(count) print(count)
Traceback (most recent call last): File "/tmp/tmpuzi4_rws/tmpgvvecvi8.py", line 4, in <module> h,w,a,b=map(int,input().split(" ")) ^^^^^^^ EOFError: EOF when reading a line
s358084306
p04046
u756518877
1558276223
Python
Python (3.4.3)
py
Runtime Error
719
5144
323
# -*- coding: utf-8 -*- import math #入力 h,w,a,b=map(int,input().split(" ")) count=0 for i in range(1,h-a+1): count=count+math.factorial(b+i-1)/(math.factorial(b)*math.factorial(i-1))*\ math.factorial(w-b-1+h-i)/(math.factorial(w-b-1)*math.factorial(h-i)) count=count%(1000000000+7) count=int(count) print(count)
Traceback (most recent call last): File "/tmp/tmptasung6p/tmpfe6odxdk.py", line 4, in <module> h,w,a,b=map(int,input().split(" ")) ^^^^^^^ EOFError: EOF when reading a line
s051722083
p04046
u771800319
1554847897
Python
Python (3.4.3)
py
Runtime Error
2104
3480
545
def combination(n,r): a,b=1,1 if r==0: return 1 if n-r<int(n/2): r=n-r for i in range(r): a*=n-i b*=i+1 return int(a/b) if __name__=='__main__': H,W,A,B=map(int, input().split()) P=0 for i in range(H-A): if i==H-A-1: P+=combination(B+i,i)*combination(W-B+H-i-2,W-B-1) else: P+=combination(B+i,i)*(combination(W-B+H-i-2,W-B-1)-\ combination(W-B+H-i-3,W-B-1)) mod=P % (10**9+7) print(mod)
Traceback (most recent call last): File "/tmp/tmp2fkrzrvs/tmpaq4kl60x.py", line 16, in <module> H,W,A,B=map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s383555607
p04046
u614314290
1553738619
Python
Python (3.4.3)
py
Runtime Error
20
3064
513
S = input() #"3 2" W, H = map(int, S.split()) STAGE = [["*" for x in range(W)] for y in range(H)] def set_v(p, v): STAGE[p[1]][p[0]] = v def get_v(p): return STAGE[p[1]][p[0]] def print_stage(): for x in STAGE: print(*x, sep="") def search(cp, c): cx, cy = cp for np in ((cx+1, cy), (cx, cy+1)): nx, ny = np if W<=nx or H<=ny: continue if get_v(np) == "E": return c + 1 c = search(np, c) return c S = (0, 0) E = (W-1, H-1) set_v(S, "S") set_v(E, "E") c = 0 c = search(S, c) print(c)
Traceback (most recent call last): File "/tmp/tmpdxbbff0r/tmpn3i6fz8_.py", line 1, in <module> S = input() #"3 2" ^^^^^^^ EOFError: EOF when reading a line
s268671799
p04046
u268516119
1553111410
Python
Python (3.4.3)
py
Runtime Error
2111
793432
237
import numpy as np H,W,A,B=map(int,input().split()) memo=np.ones((H,W),int) for i in range(1,H): for j in range(W): if i>=H-A and j <B: memo[i][j]=0 elif j!=0:memo[i][j]=(memo[i-1][j]+memo[i][j-1])%(10**9+7) print(memo[H-1][W-1])
Traceback (most recent call last): File "/tmp/tmpk52vpw08/tmpnx0xufjw.py", line 2, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s816689645
p04046
u528744583
1549757154
Python
Python (3.4.3)
py
Runtime Error
20
3064
729
mod = 1000000007 H, W, A, B = map(int, raw_input().split()) factorial = [1] for n in xrange(1, H+W): factorial.append(factorial[n-1]*n%mod) def power(x, y): if y == 0 : return 1 elif y == 1 : return x % mod elif y % 2 == 0 : return power(x, y/2)**2 % mod else : return power(x, y/2)**2 * x % mod inverseFactorial = [0] * (H+W) inverseFactorial[H+W-1] = power(factorial[H+W-1], mod-2) for n in xrange(H+W-2, -1, -1): inverseFactorial[n] = inverseFactorial[n+1] * (n+1) % mod def combi(n, m): return factorial[n] * inverseFactorial[m] * inverseFactorial[n-m] % mod sum = 0 for i in xrange(B+1, W+1): sum = (sum + combi(H-A-1+i-1, i-1) * combi(A-1+W-i, W-i)) % mod print sum
File "/tmp/tmp0r5i_w37/tmpt10mcruq.py", line 25 print sum ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s754140731
p04046
u171366497
1547516657
Python
Python (3.4.3)
py
Runtime Error
2104
3512
387
H,W,A,B=map(int,input().split()) def kaijo(a): x=1 for i in range(a): x=x*(i+1) return x def con(a,b): x=kaijo(a) y=kaijo(b) z=kaijo(a-b) res = x/y/z return res def calc(x,y): res = con(x+y-2,x-1) return res all = calc(H,W) for i in range(B): x=i+1 k = calc(x,H-A)*calc(A,W-x) all=all-k result=int(all)%(7+10**9) print(result)
Traceback (most recent call last): File "/tmp/tmpe4azjebz/tmpsh0uuh02.py", line 1, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s778378142
p04046
u171366497
1547516581
Python
Python (3.4.3)
py
Runtime Error
2104
3504
363
H,W,A,B=map(int,input().split()) def kaijo(a): x=1 for i in range(a): x=x*(i+1) return x def con(a,b): x=kaijo(a) y=kaijo(b) z=kaijo(a-b) res = x/y/z return res def calc(x,y): res = con(x+y-2,x-1) return res all = calc(H,W) for i in range(B): x=i+1 k = calc(x,H-A)*calc(A,W-x) all=all-k print(int(all))
Traceback (most recent call last): File "/tmp/tmp5ql259mu/tmpq28b8vlz.py", line 1, in <module> H,W,A,B=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s819243823
p04046
u227379863
1545918709
Python
Python (3.4.3)
py
Runtime Error
154
13508
725
H, W, A, B = map(int, input().split()) answer = 0 mod = 1000000007 factorial = [1] for n in range(1, H+W): factorial.append(factorial[n-1]*n%mod) def power(x, y): if y == 0: return 1 elif y == 1: return x % mod elif y % 2 == 0: return power(x, y/2)**2%mod else: return power(x, y/2)**2*x%mod inverseFactorial = [0] * (H+W) inverseFactorial[H+W-1] = power(factorial[H+W-1], mod-2) for n in range(H+W-2, -1, -1): inverseFactorial[n] = inverseFactorial[n+1] * (n+1) % mod def combi(n, m): return factorial[n] * inverseFactorial[m] *inverseFactorial[n-m]%mod for i in range(B+1, W+1): answer = (answer + combi(H-A-2+i, i-1)*combi(A+W-i-1,W-i)) % mod print(answer)
Traceback (most recent call last): File "/tmp/tmpqf15nrgs/tmppa2h8g9t.py", line 1, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s350229894
p04046
u227379863
1545918542
Python
Python (3.4.3)
py
Runtime Error
18
3064
725
mod = 1000000007 factorial = [1] for n in range(1, H+W): factorial.append(factorial[n-1]*n%mod) def power(x, y): if y == 0: return 1 elif y == 1: return x % mod elif y % 2 == 0: return power(x, y/2)**2%mod else: return power(x, y/2)**2*x%mod inverseFactorial = [0] * (H+W) inverseFactorial[H+W-1] = power(factorial[H+W-1], mod-2) for n in range(H+W-2, -1, -1): inverseFactorial[n] = inverseFactorial[n+1] * (n+1) % mod def combi(n, m): return factorial[n] * inverseFactorial[m] *inverseFactorial[n-m]%mod H, W, A, B = map(int, input().split()) answer = 0 for i in range(B+1, W+1): answer = (answer + combi(H-A-2+i, i-1)*combi(A+W-i-1,W-i)) % mod print(answer)
Traceback (most recent call last): File "/tmp/tmpy6w46iy0/tmpz1s5uia4.py", line 3, in <module> for n in range(1, H+W): ^ NameError: name 'H' is not defined
s815295226
p04046
u513081876
1544753025
Python
Python (3.4.3)
py
Runtime Error
87
12404
482
H, W, A, B = map(int, input().split()) ans = 0 MOD = 10**9 + 7 N = H + W - 2 fac = [1] * N inv = [1] * N # 階乗 for i in range(1, N): fac[i] = (fac[i - 1] * i) % MOD # 逆元 inv[N - 1] = pow(fac[N - 1], mod - 2, mod) for i in range(N - 1, 0, -1): inv[i - 1] = (inv[i] * i) % MOD def f(x, y): ans = fac[x + y] * inv[x] * inv[y] % MOD return ans for x in range(B, W): ans += f(x, H - A - 1) * f(W - 1 - x, A - 1) ans %= MOD print(ans % MOD)
Traceback (most recent call last): File "/tmp/tmpfol7z94c/tmpoo1vrk23.py", line 1, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s696267913
p04046
u782098901
1541277883
Python
Python (3.4.3)
py
Runtime Error
17
2940
342
import math const MOD = 1000000007 def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n - r)) def main(): H, W, A, B = map(int, input().split()) nr = 0 for i in range(1, N - A + 1): nr = nr + comb(i - 1, B + i - 2) * comb(m - b - 1, m + n - b - i - 1) % MOD print(nr % MOD) main()
File "/tmp/tmp1z7zbw8y/tmpfyhfo6_z.py", line 2 const MOD = 1000000007 ^^^ SyntaxError: invalid syntax
s002687281
p04046
u733321071
1540581466
Python
Python (3.4.3)
py
Runtime Error
2022
5212
401
# -*- coding: utf-8 -*- import math H, W, A, B = map(int, input().split()) union_sum = 0 i = 0 for n in range(B, W): m = H - A - 1 + n tmp_a = math.factorial(m) / (math.factorial(n) * math.factorial(m - n)) tmp_b = math.factorial(A - B + W - 2 - i) / (math.factorial(A - 1) * math.factorial(W - B - 1 - i)) union_sum += tmp_a * tmp_b i += 1 print(int(union_sum % (10**9 + 7)))
Traceback (most recent call last): File "/tmp/tmpcbm9o4az/tmp5m3fwla0.py", line 5, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s457266105
p04046
u733321071
1540581389
Python
Python (3.4.3)
py
Runtime Error
2023
5208
387
# -*- coding: utf-8 -*- import math H, W, A, B = map(int, input().split()) union_sum = 0 i = 0 for n in range(B, W): m = H - A - 1 + n tmp_a = math.factorial(m) / (math.factorial(n) * math.factorial(m - n)) tmp_b = math.factorial(A - B + W - 2 - i) / (math.factorial(A - 1) * math.factorial(W - B - 1 - i)) union_sum += tmp_a * tmp_b i += 1 print(int(union_sum))
Traceback (most recent call last): File "/tmp/tmpupkd74o6/tmpzvczmu_5.py", line 5, in <module> H, W, A, B = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line