problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02768
u227085629
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int,input().split())\nm = 10**9+7\n\ndef nCr(n_, r_, m_):\n c = min(r_ , n_ - r_)\n bunshi = 1\n bunbo = 1\n for i in range(1,c+1):\n bunshi = bunchi * (n_+1-i) % m_\n bunbo = bunbo * i % m_\n return bunshi * pow(bunbo, m_-2, m_) % m_\n\n\nans = pow(2,n,m)-1\nans -= nCr(n,a,m)\nans %= m\nans -= nCr(n,b,m)\nans %= m\nprint(ans)', 'n,a,b = map(int,input().split())\nm = 10**9+7\n\ndef nCr(n_, r_, m_):\n c = min(r_ , n_ - r_)\n bunshi = 1\n bunbo = 1\n for i in range(1,c+1):\n bunshi = bunshi * (n_+1-i) % m_\n bunbo = bunbo * i % m_\n return bunshi * pow(bunbo, m_-2, m_) % m_\n\n\nans = pow(2,n,m)-1\nans -= nCr(n,a,m)\nans %= m\nans -= nCr(n,b,m)\nans %= m\nprint(ans)']
['Runtime Error', 'Accepted']
['s040761094', 's181387960']
[3064.0, 3064.0]
[17.0, 142.0]
[333, 333]
p02768
u230621983
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int, input().split())\n\nmod = 1000000007\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = n\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nprint(pow(2,n,mod)-1-(cmb(n,a,mod)+cmb(n,b,mod)))', 'n, a, b = map(int, input().split())\nmod = 7+10**9\ndef comb(n,c,mod):\n x = 1\n y = 1\n for i in range(n-c+1,n+1):\n x = x*i%mod\n for j in range(1,c+1):\n y = y*j%mod\n return (x * pow(y, mod-2, mod)) % mod\nc_a = comb(n,a,mod)\nc_b = comb(n,b,mod)\nprint((pow(2,n,mod)-1 -(c_a+c_b))%mod)']
['Time Limit Exceeded', 'Accepted']
['s665898645', 's519643817']
[217384.0, 3064.0]
[2120.0, 109.0]
[556, 289]
p02768
u232873434
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import numpy as np\nn, a, b = map(int, input().split())\n\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % p\n\n\np = 10 ** 9 + 7\nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\nfor i in range(2, n + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\nprint(2**n%p-cmb(n, a, p)-cmb(n, b, p))', 'def cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nn, a, b = map(int, input().split())\n\np = 10 ** 9 + 7\n\nprint((2 ** n%p - cmb(n, a,p) - cmb(n, b,p)) - 1)', 'from scipy.special import comb\na = comb(n, r, exact=True)\n\nimport numpy as np\nn, a, b = map(int, input().split())\n\np = 10 ** 9 + 7\n\nprint((2**n-comb(n, a, exact=True)-comb(n, b, exact=True))%p-1)', 'k = 2 *10**5\nmod = 10**9+7\n\nn, a, b = map(int,input().split())\n\nmodinv_table = [-1]*(k+1)\nfor i in range(1,k+1):\n modinv_table[i] = pow(i,-1,mod)\n\ndef binomial_coefficients(n,k):\n ans = 1\n for i in range(k):\n ans *= n-i\n ans *= modinv_table[i+1]\n ans %= mod\n return ans\nprint((pow(2,n,mod)-binomial_coefficients(n,a)-binomial_coefficients(n,b)-1)%mod)']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s266347348', 's462792128', 's573963817', 's062195117']
[220644.0, 200512.0, 20732.0, 16812.0]
[2122.0, 2106.0, 287.0, 395.0]
[452, 562, 195, 384]
p02768
u242196904
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['mod = 5 #int(1e9) + 7\nn, a, b = map(int, input().split())\n\ndef aaa(base, n):\n# base = 2\n ans = 1\n nn = n\n while True:\n # print(base, nn)\n if nn == 0:\n break\n if nn % 2 == 0:\n base = base ** 2\n base = base % mod\n nn /= 2\n else:\n ans *= base\n ans = ans % mod\n nn -= 1\n return ans\n\nxn = aaa(2, n)\n\ndef mul(a, b):\n return ((a % mod) * (b % mod)) % mod\n\ndef power(x, y):\n if y == 0 : return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return power(x, y//2)**2 % mod\n else : return power(x, y//2)**2 * x % mod\n\ndef div(a, b):\n return mul(a, power(b, mod-2))\n\n\ndef fac(start, length, mod):\n x = 1\n for k in range(start, start + length):\n x *= k\n x %= mod\n return x\n\naa = fac(n - a + 1 , a, mod)\naaa = fac(1, a, mod)\nxa = div(aa, aaa)\nif aa == 0:\n if aaa == 0:\n xa = 1\n\n\nbb = fac(n - b + 1 , b, mod)\nbbb = fac(1, b, mod)\nxb = div(bb, bbb)\nif bb == 0:\n if bbb == 0:\n xb = 1\n \n\nx = xn - xa - xb - 1\nx = x%mod\nif x < 0:\n x += mod\nprint(x)', '\ndef power(x, y, mod):\n \n\n if y == 0 : return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return power(x, y//2, mod)**2 % mod\n else : return power(x, y//2, mod)**2 * x % mod\n\n\ndef mul(a, b, mod):\n \n return ((a % mod) * (b % mod)) % mod\n\ndef div(a, b, mod):\n \n if a == b:\n return 1\n return mul(a, power(b, mod-2, mod), mod)\n\n\ndef factorial_part(start, last, mod):\n \n assert(start <= last)\n x = 1\n for k in range(start, last+1):\n x *= k\n x %= mod\n return x\n\n\nmod = int(1e9) + 7\nn, a, b = map(int, input().split())\n\nnCa = div(factorial_part(n - a + 1, n, mod), factorial_part(1, a, mod), mod)\nnCb = div(factorial_part(n - b + 1, n, mod), factorial_part(1, b, mod), mod)\nn2 = power(2, n, mod)\nans = n2 - nCa - nCb - 1\nans = ans % mod\nif ans < 0:\n ans += mod\nprint(ans)']
['Wrong Answer', 'Accepted']
['s507088631', 's490183426']
[3064.0, 3064.0]
[70.0, 145.0]
[1147, 1386]
p02768
u243312682
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
["def main():\n n, a, b = map(int, input().split())\n mod = 10 ** 9 + 7 \n \n def modpow(x, n, mod):\n res = 1\n while n:\n if n % 2:\n res *= x % mod\n x *= x % mod\n n >>= 1\n return res\n \n def cmb(n, r, mod):\n \n nume = 1\n for i in range(n-r+1, n+1):\n nume = nume * i\n \n deno = 1\n for j in range(1, r+1):\n deno = deno * jc # % mod\n d = modpow(deno, mod-2, mod)\n return nume * d# % mod\n \n all_cmb = pow(2, n, mod) - 1\n bad_a = cmb(n, a, mod)\n bad_b = cmb(n, b, mod) \n print((all_cmb-bad_a-bad_b) % mod)\n\nif __name__ == '__main__':\n main()\n\n", "def main():\n n, a, b = map(int, input().split())\n mod = 10 ** 9 + 7 \n \n def modpow(x, n, mod):\n res = 1\n while n:\n if n % 2:\n res *= x % mod\n x *= x % mod\n n >>= 1\n return res\n \n def cmb(n, r):\n \n nume = 1\n for i in range(n-r+1, n+1):\n nume = nume * i % mod\n \n deno = 1\n for j in range(1, r+1):\n deno = deno * j % mod\n d = modpow(deno, mod-2, mod)\n return nume * d\n \n all_cmb = pow(2, n, mod) -\u30001\n bad_a = cmb(n, a)\n bad_b = cmb(n, b) \n print((all_cmb-bad_a-bad_b) % mod)\n\nif __name__ == '__main__':\n main()", "def main():\n n, a, b = map(int, input().split())\n mod = 10 ** 9 + 7 \n \n def modpow(x, n, mod):\n res = 1\n while n:\n if n % 2:\n res *= x % mod\n x *= x % mod\n n >>= 1\n return res\n \n def cmb(n, r, mod):\n \n nume = 1\n for i in range(n-r+1, n+1):\n nume = nume * i % mod\n \n deno = 1\n for j in range(1, r+1):\n deno = deno * j % mod\n d = modpow(deno, mod-2, mod)\n return nume * d % mod\n \n all_cmb = pow(2, n, mod) - 1\n bad_a = cmb(n, a, mod)\n bad_b = cmb(n, b, mod) \n print((all_cmb-bad_a-bad_b) % mod)\n\nif __name__ == '__main__':\n main()\n\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s483019731', 's665338488', 's670767989']
[9692.0, 8792.0, 9204.0]
[2205.0, 24.0, 102.0]
[773, 754, 775]
p02768
u243714267
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def powerDX(n, r, mod):\n if r == 0: return 1\n if r%2 == 0:\n return powerDX(n*n % mod, r//2, mod) % mod\n if r%2 == 1:\n return n * powerDX(n, r-1, mod) % mod\n \ndef combination(n, r, mod=10**9+7):\n n1, r = n+1, min(r, n-r)\n numer = denom = 1\n for i in range(1, r+1):\n numer = numer * (n1-i) % mod\n denom = denom * i % mod\n return numer * powerDX(denom, mod-2, mod) % mod\n \nans = pow(2, n, mod) - 1\nans -= combination(n, a, mod)\nans -= combination(n, b, mod)\nans += 3*mod\nans %= mod\nprint(ans)', 'def powerDX(n, r, mod):\n if r == 0: return 1\n if r%2 == 0:\n return powerDX(n*n % mod, r//2, mod) % mod\n if r%2 == 1:\n return n * powerDX(n, r-1, mod) % mod\n \ndef combination(n, r, mod=10**9+7):\n n1, r = n+1, min(r, n-r)\n numer = denom = 1\n for i in range(1, r+1):\n numer = numer * (n1-i) % mod\n denom = denom * i % mod\n return numer * pow(denom, mod-2, mod) % mod\n \nans = pow(2, n, mod) - 1\nans -= combination(n, a, mod)\nans -= combination(n, b, mod)\nans += 3*mod\nans %= mod\nprint(ans)', 'def powerDX(n, r, mod):\n if r == 0: return 1\n if r%2 == 0:\n return powerDX(n*n % mod, r//2, mod) % mod\n if r%2 == 1:\n return n * powerDX(n, r-1, mod) % mod\n \ndef combination(n, r, mod=10**9+7):\n n1, r = n+1, min(r, n-r)\n numer = denom = 1\n for i in range(1, r+1):\n numer = numer * (n1-i) % mod\n denom = denom * i % mod\n return numer * powerDX(denom, mod-2, mod) % mod\n \nans = power(2, n, mod) - 1\nans -= combination(n, a, mod)\nans -= combination(n, b, mod)\nans += 3*mod\nans %= mod\nprint(ans)', 'n, a, b = map(int, input().split())\nmod = 10**9 + 7\n \ndef powerDX(n, r, mod):\n if r == 0: return 1\n if r%2 == 0:\n return pow(n*n % mod, r//2, mod) % mod\n if r%2 == 1:\n return n * pow(n, r-1, mod) % mod\n \ndef combination(n, r, mod=10**9+7):\n n1, r = n+1, min(r, n-r)\n numer = denom = 1\n for i in range(1, r+1):\n numer = numer * (n1-i) % mod\n denom = denom * i % mod\n return numer * pow(denom, mod-2, mod) % mod\n \nans = pow(2, n, mod) - 1\nans -= combination(n, a, mod)\nans -= combination(n, b, mod)\nans += 3*mod\nans %= mod\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s016678089', 's210997413', 's728784351', 's997610599']
[3064.0, 3064.0, 3064.0, 3064.0]
[20.0, 17.0, 18.0, 130.0]
[526, 522, 528, 568]
p02768
u252828980
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['N,A,B=map(int,input().split())\nMOD=10**9+7\n\ndef comb(n,r):\n\tif n<r:\n\t\treturn 0\n\tl = min(r,n-r)\n\tm=n\n\tu=1\n\tfor _i in range(l):\n\t\tu*=m\n\t\tm-=1\n\treturn u//fact(l)\n \nprint((pow(2,N,MOD)-1-comb(N,A)-comb(N,B))%MOD)\n', 'a,b,c = map(int,input().split())\nMOD = 10**9+7\n\ndef comb(n,r):\n res = 1\n fac = 1\n for i in range(r):\n res *= n-i\n res %= MOD\n fac *= i+1\n fac %= MOD\n return res*pow(fac,MOD-2,MOD)%MOD \n\np = pow(2,a,MOD)\nq = comb(a,b)\nr = comb(a,c)\nans = (p-q-r-1)%MOD\nprint(ans)']
['Runtime Error', 'Accepted']
['s724518213', 's712988229']
[3620.0, 3188.0]
[2104.0, 157.0]
[235, 301]
p02768
u257018224
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b =map(int, input().split())\nc=2**n-1\nimport math\nc=c-math.factorial(n-a+1) // math.factorial(a)-math.factorial(n-b+1) // math.factorial(b)\nprint(c%(10**9+7))', 'n,a,b=map(int,input().split())\n\ndef combination(n,x,mod):\n bunbo=1\n bunshi=1\n for i in range(x):\n bunbo*=n-i\n bunshi*=i\n buubo=bunbo%mod\n bunshi=bunshi%mod\n return (bunshi//bunshi)%mod\n\nmod=1000000007\nanswer=2**n-1\nanswer-=combination(n,a,mod)\nanswer-=combination(n,b,mod)\nanswer=answer%mod\nprint(answer)\n', 'n,a,b=map(int,input().split())\ndef combination(n, a, mod):\n bunbo = 1\n bunshi = 1\n for i in range(a):\n bunshi *= n-i\n bunshi = bunshi%mod\n bunbo *= a-i\n bunbo = bunbo%mod\n \n return bunshi*pow(bunbo, mod-2, mod)%mod\n \n \nmod = 1000000007\nanswer = pow(2, n, mod)\nanswer -= 1\nanswer -= combination(n, a, mod)\nanswer -= combination(n, b, mod)\nprint(answer%mod)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s047580432', 's409719078', 's857216255']
[199264.0, 199376.0, 3064.0]
[2106.0, 2106.0, 149.0]
[163, 345, 416]
p02768
u257265865
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from operator import mul\nfrom functools import reduce\nn,a,b=map(int,input(),split())\ndef cmb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\nx=cmb(n,a)+cmb(n,b)\ny=pow(2,n)-1\nans=(y-x%(10**9+7))\nprint(ans)', '\nn,a,b=map(int,input().split\nmod = 10**9+7\nMAX_N = 10**6\n\nfact = [1]\nfact_inv = [0]*(MAX_N+4)\nfor i in range(MAX_N+3):\n fact.append(fact[-1]*(i+1)%mod)\n\nfact_inv[-1] = pow(fact[-1],mod-2,mod)\nfor i in range(MAX_N+2,-1,-1):\n fact_inv[i] = fact_inv[i+1]*(i+1)%mod\n\n\ndef mod_comb_k(n,k,mod):\n return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod\n\n\n\nx=mod_comb_k(n,a,mod)+mod_comb_k(n,b,mod)\ny=((pow(2,n)-1)%(10**9+7))\nans=(y-x%(10**9+7))\nwhile ans<0:\n ans+=10**9+7\nprint(ans)\n\n', 'n,a,b=map(int,input().split())\ndef comb(n,k):\n nCk = 1\n MOD = 10**9+7\n\n for i in range(n-k+1, n+1):\n nCk *= i\n nCk %= MOD\n\n for i in range(1,k+1):\n nCk *= pow(i,MOD-2,MOD)\n nCk %= MOD\n return nCk\n\nx=pow(2,n,10**9+7)-1\ny=comb(n,a)+comb(n,b)\nans=x-y\n\n\n\n\n\nwhile ans<0:\n ans+=10**9+7\nprint(ans)\n\n\n\n\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s009139655', 's934979984', 's943912306']
[3572.0, 2940.0, 3188.0]
[23.0, 17.0, 1516.0]
[315, 495, 347]
p02768
u258933429
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\n\n\ndef choose(x, y, m):\n v = 1\n for i in range(0, y):\n\n v = (v * (x - i) * pow(i + 1, m - 2, m)) % m\n\n return v\n\n\nm = 10**9 + 7\nprint((pow(2, n, m) - choose(n, a, m) - choose(n, b, m)) % m)\n', 'n, a, b = map(int, input().split())\nm = 10**9 + 7\n\n\ndef choose(x, y):\n v = 1\n for i in range(0, y):\n v = (v * (x - i) * pow(i + 1, m - 2, m)) % m\n return v\n\n\nprint((pow(2, n, m) - 1 - choose(n, a) - choose(n, b)) % m)\n']
['Wrong Answer', 'Accepted']
['s204881047', 's383824695']
[3060.0, 3060.0]
[1511.0, 1533.0]
[241, 234]
p02768
u259755734
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
[' import sys\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nns = lambda: stdin.readline().rstrip()\nna = lambda: list(map(int, stdin.readline().split()))\n\n# code here\nn, a, b = na()\nmod = 1000000007\n\ndef c(n, r):\n nu = 1\n de = 1\n for i in range(r):\n \n nu = nu * (n - i) % mod\n \n de = de * (i + 1) % mod\n \n return nu * pow(de, mod - 2, mod) % mod\n\nprint((pow(2, n, mod) - c(n, a) - c(n, b) - 1) % mod)\n', 'import sys\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nns = lambda: stdin.readline().rstrip()\nna = lambda: list(map(int, stdin.readline().split()))\n\n# code here\nn, a, b = na()\nmod = 1000000007\n\ndef c(n, r):\n nu = 1\n de = 1\n for i in range(r):\n \n nu = nu * (n - i) % mod\n \n de = de * (i + 1) % mod\n \n return nu * pow(de, mod - 2, mod) % mod\n\nprint((pow(2, n, mod) - c(n, a) - c(n, b) - 1) % mod)\n']
['Runtime Error', 'Accepted']
['s996147964', 's325065985']
[2940.0, 3064.0]
[17.0, 152.0]
[504, 502]
p02768
u265506056
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['N,A,B=map(int,input().split())\nMOD=10**9+7\n\ndef calculate_combination(n,k):\n x,y=1,1\n for i in range(k):\n x=x*(n-i)%MOD\n y=y*(k-1)%MOD\n return x*pow(y,MOD-2,MOD)%MOD\n\nans=pow(2,N,MOD)-1-calculate_combination(N,A)-calculate_combination(N,B)\nwhile ans<0:\n ans+=MOD\nprint(ans)', 'N,A,B=map(int,input().split())\nMOD=10**9+7\n\ndef calculate_combination(n,k):\n x,y=1,1\n for i in range(k):\n x=x*(n-i)%MOD\n y=y*(k-i)%MOD\n return x*pow(y,MOD-2,MOD)%MOD\n\nans=pow(2,N,MOD)-1-calculate_combination(N,A)-calculate_combination(N,B)\nwhile ans<0:\n ans+=MOD\nprint(ans)']
['Wrong Answer', 'Accepted']
['s336300978', 's632206639']
[3064.0, 3064.0]
[147.0, 142.0]
[299, 299]
p02768
u272336707
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['N, A, B = map(int, input().split())\nmo = 10 ** 9 + 7\ndef hanaya(n, x):\n if x == 1:\n return n\n else:\n return ((hanaya(n, x-1))*((n-x+1)/x))%mo\n\nans = (pow(2, N) - 1 ) % mo\nprint(int(ans))', 'N, A, B = map(int, input().split())\nmo = 1000000007\nA_val = 1\nfor i in range(A):\n A_val = ((A_val * (N - i) * pow(i+1, mo-2, mo))) % mo\nB_val = 1\nfor i in range(B):\n B_val = ((B_val * (N - i) * pow(i+1, mo-2, mo))) % mo\n \nans = (pow(2, N, mo) - 1 - A_val - B_val) % mo\nprint(ans)']
['Wrong Answer', 'Accepted']
['s707681633', 's956497448']
[199376.0, 3064.0]
[2106.0, 1568.0]
[206, 288]
p02768
u274635633
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b=map(int,input().split())\nm=10**9+7\n\n\n\n\n\n\ndef gyakugen( a, m ):\n b = m\n x, y = 1, 0\n while b>0:\n q = a // b\n a, b = b, a-q*b\n x, y = y, x-q*y\n return x if x>0 else x+m\n\n\nimport sys\nsys.setrecursionlimit(10**9)\n\ndef perm_remainder(n,r,m):\n if r>=1:\n return (perm_remainder(n-1,r-1,m)*n)%m\n else:\n return 1\n\n\n\ndef comb_remainder(n,r,m):\n r=min(r,n-r)\n return (perm_remainder(n,r,m)*gyakugen(perm_remainder(r,r,m),m))%m\n\n\n\n\ndef power_remainder(a,n,m):\n a=a%m\n bi=str(format(n,"n"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %m\n if bi[i]=="1":\n res=(res*a) %m\n return res\n\n\nprint(power_remainder(2,n,m)-1-comb_remainder(n,a,m)-comb_remainder(n,b,m))', 'import math\nn,a,b=map(int,input().split())\nna=1\nm=7+10**9\ndef gyakugen(a,b):\n r=[1,0,a]\n w=[0,1,b]\n while(w[2]!=1):\n q=r[2]//w[2]\n r2=w\n w2=[r[0]-q*w[0],r[i]-q*w[i],r[2]-q*w[2]]\n r=r2\n w=w2\n return (b+w[0]%b)%b\nans=1\nfor i in range(n):\n ans*=2\n if ans>=m:\n ans%=m\n\nfor i in range(1,n+1):\n na=na*i%m\nnb=na\nfor i in range(1,n-a+1):\n na=na*gyakugen(i,m)%m\nfor i in range(1,a+1):\n na=na*gyakugen(i,m)%m\nfor i in range(1,n-b+1):\n nb=nb*gyakugen(i,m)%m\nfor i in range(1,b+1):\n nb=nb*gyakugen(i,m)%m \nans=ans-na-nb-1\nans%=m\nprint(ans)', 'import math\nn,a,b=map(int,input().split())\nans=2**n-1\nans-=math.factorial(n)/(math.factorial(n-a)*math.factorial(a))\nans-=math.factorial(n)/(math.factorial(n-b)*math.factorial(b))\nans%=7+10**9\nprint(ans)', 'import math\nn,a,b=map(int,input().split())\nans=2**n\nans-=math.factorial(n)/(math.factorial(n-a)*math.factorial(a))\nans-=math.factorial(n)/(math.factorial(n-b)*math.factorial(b))\nans%=7+10**9\nprint(ans)', 'n,a,b=map(int,input().split())\nm=10**9+7\n\n\n\n\n\n\ndef gyakugen( a, m ):\n b = m\n x, y = 1, 0\n while b>0:\n q = a // b\n a, b = b, a-q*b\n x, y = y, x-q*y\n return x if x>0 else x+m\n\n\nimport sys\nsys.setrecursionlimit(10**9)\n\ndef perm_remainder(n,r,m):\n if r>=1:\n return (perm_remainder(n-1,r-1,m)*n)%m\n else:\n return 1\n\n\n\ndef comb_remainder(n,r,m):\n r=min(r,n-r)\n return (perm_remainder(n,r,m)*gyakugen(perm_remainder(r,r,m),m))%m\n\n\n\n\ndef power_remainder(a,x,m):\n a=a%m\n bi=str(format(x,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %m\n if bi[i]=="1":\n res=(res*a) %m\n return res\n\n\nprint((power_remainder(2,n,m)-1-comb_remainder(n,a,m)-comb_remainder(n,b,m))%m)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s391741106', 's606095787', 's785457432', 's894279272', 's365538958']
[181236.0, 3064.0, 199340.0, 199348.0, 181236.0]
[882.0, 2104.0, 2106.0, 2106.0, 883.0]
[1218, 605, 203, 201, 1222]
p02768
u277104886
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\n\nMOD = 10**9 + 7\nN = pow(2,n,MOD)\n\ndef com(n,r):\n s = 1\n for i in range(n-r+1, n+1):\n s *= i\n s %= MOD\n\n t = 1\n for j in range(1,r+1):\n t *= j\n t %= MOD\n\n\n return s * pow(t,MOD-2, MOD) % MOD\n\nprint((N - com(n, a) - com(n, b)) % (MOD))', 'n, a, b = map(int, input().split())\n\nMOD = 10**9 + 7\nN = pow(2,n,MOD)\n\ndef com(n,r):\n s = 1\n for i in range(n-r+1, n+1):\n s *= i\n s %= MOD\n\n t = 1\n for j in range(1,r+1):\n t *= j\n t %= MOD\n\n\n return s * pow(t,MOD-2, MOD) % MOD\n\nprint((N - com(n, a) - com(n, b) - 1) % (MOD))']
['Wrong Answer', 'Accepted']
['s133664643', 's553898959']
[9080.0, 9192.0]
[110.0, 115.0]
[313, 317]
p02768
u277312083
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from scipy.misc import comb\nn, a, b = map(int, input().split())\nans = 1\nif n % 2 == 0:\n nn = n\nelse:\n nn = n + 1\nfor k in range(1, nn // 2):\n ans += 2 * comb(n, k, exact = True)\nif n % 2 == 0:\n ans += comb(n, n // 2, exact = True)\nans -= comb(n, a, exact = True) + comb(n, b, exact = True)\nprint(ans % (10**9 + 7))', 'from scipy.misc import comb\nn, a, b = map(int, input().split())\nl = [comb(n, k, exact = True) % (10**9 + 7) for k in range(1, n + 1)]\nans = 0\nfor i in range(n):\n if i != a - 1 and i != b - 1:\n ans += l[i]\nprint(ans)\n', 'MOD = pow(10, 9) + 7\n\ndef modinv(a, mod):\n return pow(a, mod - 2, mod) % mod\n\ndef comb(n, r, mod):\n r = min(r, n - r)\n res = 1\n for i in range(r):\n res = res * (n - i) % mod\n res = res * modinv(i + 1, mod) % mod\n return res\n\nn, a, b = map(int, input().split())\n\nans = (pow(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)) % MOD\n\nprint(ans)\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s853423673', 's927178908', 's350197968']
[15280.0, 15268.0, 9200.0]
[2108.0, 2109.0, 1250.0]
[326, 226, 372]
p02768
u282574080
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = list(map(int,input().split(" ")))\nmod = 10**9 + 7\n\ndef cmb(n, r):\n if n - r < r: r = n - r\n if r == 0: return 1\n if r == 1: return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result = int(numerator[k]) * result % mod\n\n return result\n \n def m_power_n_mod(m,n,mod):\n q = 1\n f = m\n while(n > 0):\n c = n % 2\n n = int((n-c)/2)\n q = (q * f**c) % mod\n f = f**2 % mod\n return q\n \nprint((m_power_n_mod(2,n,mod) - 1 - cmb(n,a)%mod - cmb(n,b)%mod)%mod)', 'n,a,b = list(map(int,input().split(" ")))\nmod = 10**9 + 7\n\ndef cmb(n, r):\n if n - r < r: r = n - r\n if r == 0: return 1\n if r == 1: return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result = int(numerator[k]) * result % mod\n\n return result\n\ndef m_power_n_mod(m,n,mod):\n q = 1\n f = m\n while(n > 0):\n c = n % 2\n n = int((n-c)/2)\n q = (q * f**c) % mod\n f = f**2 % mod\n return q\n\nprint((m_power_n_mod(2,n,mod) - 1 - cmb(n,a)%mod - cmb(n,b)%mod)%mod)']
['Runtime Error', 'Accepted']
['s300641560', 's039708036']
[3064.0, 27700.0]
[17.0, 681.0]
[877, 873]
p02768
u284363684
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['# input\nn, a, b = map(int, input().split())\nmod = 0 ** 9 + 7\n\n\n\ndef fur(n, r):\n p, q = 1, 1\n for i in range(r):\n p = p * (n - i) % mod\n q = q * (i + 1) % mod\n return p * pow(q, mod - 2, mod) % mod\n\n\nnca = fur(n, a)\nncb = fur(n, b)\nans = ((pow(2, n, mod) - 1) - nca - ncb) % mod\n\nprint(ans)', '# input\nn, a, b = map(int, input().split())\nmod = 10 ** 9 + 7\nal = (pow(2, n, mod) - 1)\n\n\n\ndef fur(n, r):\n p, q = 1, 1\n for i in range(r):\n p = p * (n - i) % mod\n q = q * (i + 1) % mod\n return p * pow(q, mod - 2, mod) % mod\n\n\nnca = fur(n, a)\nncb = fur(n, b)\nans = (al - nca - ncb) % mod\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s485065261', 's605235758']
[3064.0, 3064.0]
[94.0, 153.0]
[434, 443]
p02768
u288430479
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int,input().split())\nmod = 10**9+7\n\ndef comb(N,x):\n numerator = 1\n for i in range(N-x+1,N+1):\n numerator = numerator *i%mod\n denominator = 1\n for j in range(1,x+1):\n denominator = denominator *i%mod\n d = pow(denominator,mod-2,mod)\n return (numerator*d)%mod\nal = pow(2,n,mod)-1\nac =comb(n,a)\nbc =comb(n,b)\nprint((al-ac-bc)%mod)', 'n,a,b = map(int,input().split())\nmod = 10**9+7\n\ndef comb(N,x):\n numerator = 1\n for i in range(N-x+1,N+1):\n numerator = numerator *i%mod\n denominator = 1\n for j in range(1,x+1):\n denominator = denominator *j%mod\n d = pow(denominator,mod-2,mod)\n return (numerator*d)%mod\nal = pow(2,n,mod)-1\nac =comb(n,a)\nbc =comb(n,b)\nprint((al-ac-bc)%mod)']
['Wrong Answer', 'Accepted']
['s325270576', 's395816613']
[3064.0, 3064.0]
[118.0, 117.0]
[350, 350]
p02768
u305366205
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\n\n\ndef pow_k(x, n):\n \n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n n //= 2\n\n return K * x\n\n\ntotal = pow_k(2, n) - 1\n\nnow = 1\ndiv = 1\nans = 0\nfor i in range(max(a, b) + 1):\n print(i)\n now *= (n - i)\n div *= i + 1\n if i == a-1 and i != b-1:\n total -= now // div\nprint(total % (10 ** 9 + 7))', 'n, a, b = map(int, input().split())\nmod = 10 ** 9 + 7\ntotal = pow(2, n, mod) - 1\nproduct = 1\nfor i in range(1, max(a, b) + 1):\n product *= i\n if i == a or i == b:\n total -= pow(product, mod - 2, mod)\nprint(total % mod)', 'MOD = 10 ** 9 + 7\n\n\nclass ModInt:\n def __init__(self, x):\n self.x = x % MOD\n\n def __str__(self):\n return str(self.x)\n\n __repr__ = __str__\n\n def __add__(self, other):\n return (\n ModInt(self.x + other.x) if isinstance(other, ModInt) else\n ModInt(self.x + other)\n )\n\n def __sub__(self, other):\n return (\n ModInt(self.x - other.x) if isinstance(other, ModInt) else\n ModInt(self.x - other)\n )\n\n def __mul__(self, other):\n return (\n ModInt(self.x * other.x) if isinstance(other, ModInt) else\n ModInt(self.x * other)\n )\n\n def __truediv__(self, other):\n return (\n ModInt(\n self.x * pow(other.x, MOD - 2, MOD)\n ) if isinstance(other, ModInt) else\n ModInt(self.x * pow(other, MOD - 2, MOD))\n )\n\n def __pow__(self, other):\n return (\n ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else\n ModInt(pow(self.x, other, MOD))\n )\n\n __radd__ = __add__\n\n def __rsub__(self, other):\n return (\n ModInt(other.x - self.x) if isinstance(other, ModInt) else\n ModInt(other - self.x)\n )\n\n __rmul__ = __mul__\n\n def __rtruediv__(self, other):\n return (\n ModInt(\n other.x * pow(self.x, MOD - 2, MOD)\n ) if isinstance(other, ModInt) else\n ModInt(other * pow(self.x, MOD - 2, MOD))\n )\n\n def __rpow__(self, other):\n return (\n ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else\n ModInt(pow(other, self.x, MOD))\n )\n\n\nn, a, b = map(int, input().split())\nans = pow(2, n, MOD) - 1\nproduct = ModInt(1)\ndiv = ModInt(1)\nfor i in range(b + 1):\n product *= (n - i)\n div *= i + 1\n if i == a - 1 or i == b - 1:\n ans -= product / div\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s377641319', 's704386750', 's810118980']
[236288.0, 3476.0, 3188.0]
[2107.0, 2104.0, 435.0]
[452, 231, 1938]
p02768
u306950978
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['mod = 1000000007\n\ndef mul(a, b):\n return ((a % mod) * (b % mod)) % mod\n\ndef power(s, t):\n if t == 0 : return 1\n elif t == 1 : return x % mod\n elif t % 2 == 0 : return power(s, t/2)**2 % mod\n else : return power(s, t/2)**2 * x % mod\n\ndef div(a, b):\n return mul(a, power(b, mod-2))\n \ndef cmb(a,b):\n p = 1\n q = 1\n for i in range(1,b+1):\n p = mul(p,a-i)\n for j in range(1,b+1):\n q = mul(q,j)\n return div(p,q)\n\nx,y,z = map(int,input().split(" "))\nans = 0\n\nfor i in range(1,x+1):\n if i == y or i == z:\n continue\n else:\n ans += cmb(x,i)\n\nprint(ans)', '#xCy=x!/y!(x-y)!\ndef com(x,y):\n bunb = 1\n buns = 1\n for i in range(y):\n buns = buns * (x-i) % mod\n bunb = bunb * (i+1) % mod\n\n bunb_inv = pow(bunb,mod-2,mod)\n d = (buns * bunb_inv) % mod\n return buns*pow(bunb,mod-2,mod)\n \nn,a,b = map(int,input().split())\nmod = 10**9 + 7\n\nans = pow(2,n,mod) - 1\nans -= com(n,a) + com(n,b)\n\nprint(ans%mod)']
['Runtime Error', 'Accepted']
['s333874910', 's808570815']
[3936.0, 3064.0]
[78.0, 150.0]
[632, 372]
p02768
u314089899
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['#156d\nn,a,b = map(int, input().split())\n\n##############################################\n#https://tane-no-blog.com/976/\nmod = pow(10, 9) + 7\n \ndef comb(N, x):\n \n numerator = 1\n for i in range(N-x+1, N+1):\n numerator = numerator * i % mod\n \n \n denominator = 1\n for j in range(1, x+1):\n denominator = denominator * j % mod\n \n \n d = pow(denominator, mod-2, mod)\n \n return numerator * d\n\n################################\n\ncomb_all = pow(2,n,MOD_BY) - 1 #(2**n) - 1\ncomb_a = comb(n,a)\ncomb_b = comb(n,b)\n\n#print(comb_all,comb_a,comb_b)\nprint((comb_all-comb_a-comb_b)%MOD_BY)', '#156d\nn,a,b = map(int, input().split())\n\n##############################################\n#https://tane-no-blog.com/976/\nmod = pow(10, 9) + 7\n \ndef comb(N, x):\n \n numerator = 1\n for i in range(N-x+1, N+1):\n numerator = numerator * i % mod\n \n \n denominator = 1\n for j in range(1, x+1):\n denominator = denominator * j % mod\n \n \n d = pow(denominator, mod-2, mod)\n \n return numerator * d\n\n################################\n\ncomb_all = pow(2,n,mod) - 1 #(2**n) - 1\ncomb_a = comb(n,a)\ncomb_b = comb(n,b)\n\n#print(comb_all,comb_a,comb_b)\nprint((comb_all-comb_a-comb_b)%mod)']
['Runtime Error', 'Accepted']
['s169368818', 's114024768']
[3064.0, 3064.0]
[17.0, 116.0]
[704, 698]
p02768
u318740143
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int,input().split())\ninf = 10**9 +7\nans = pow(2,n,inf)-1\ndef conbi(n,k):\n if n-k < k:\n k = n-k\n x = 1\n y = 1\n for i in range(k):\n x *= n-i\n x = x%inf\n y *= i+1\n y = y%inf\n ans1 = x* pow(y,inf-2,inf)%inf\n return ans1\nprint(conbi(n,a))\nsol = ans - conbi(n,a)- conbi(n,b)\nprint(sol)\n\n ', 'n,a,b = map(int,input().split())\ninf = 10**9 +7\nans = pow(2,n,inf)-1\ndef conbi(n,k):\n if n-k < k:\n k = n-k\n x = 1\n y = 1\n for i in range(k):\n x *= n-i\n x = x%inf\n y *= i+1\n y = y%inf\n ans = x* pow(y,inf-2,inf)%inf\n return ans\nans -= conbi(n,a) + conbi(n,b)\nans = ans%inf\nprint(ans) ']
['Runtime Error', 'Accepted']
['s016285673', 's009209854']
[3064.0, 3064.0]
[2103.0, 153.0]
[320, 305]
p02768
u333700164
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b=map(int,input().split())\nmod=10**9+7\ndef comb(n,k,mod):\n if k>n-k:\n k=n-k\n c=1\n for i in range(n-k+1,n+1):\n c*=i\n c%=mod\n d=1 \n for i in range(1,k+1):\n d*=i\n d%=mod\n return (c*pow(d,mod-2,mod))%mod\n\nans=pow(2,n,mod)-comb(n,a,mod)-comb(n,b,mod)\nprint(ans%mod)\n', 'n,a,b=map(int,input().split())\nmod=10**9+7\nfrom math import pow\ndef comb(n,k,mod):\n if k>n-k:\n k=n-k\n c=1\n for i in range(n-k+1,n+1):\n c*=i\n d=1 \n for i in range(1,k+1):\n d*=i\nreturn(c*pow(d,mod-2,mod)%mod)\n\nans=(2**n-1)-comb(n,a,mod)-comb(n,b,mod)\nreturn (ans%mod)', 'n,a,b=map(int,input().split())\nmod=10**9+7\ndef comb(n,k,mod):\n if k>n-k:\n k=n-k\n c=1\n for i in range(n-k+1,n+1):\n c*=i\n c%=mod\n d=1 \n for i in range(1,k+1):\n d*=i\n d%=mod\n return (c*pow(d,mod-2,mod))%mod\n\nans=pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)\nprint(ans%mod)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s050154364', 's734981622', 's982802194']
[9160.0, 9020.0, 9100.0]
[110.0, 25.0, 112.0]
[287, 280, 289]
p02768
u342563578
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int,input().split())\ndef kai(g):\n p = 1 \n for i in range(1,g+1):\n p = p*i\n return p\ndef comb(n,k):\n return kai(n)/(kai(k)*kai(n-k))\nprint(2**n-1-comb(n,a)-comb(n,b))\n', 'n,a,b = map(int,input().split())\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, n + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\nv = int(pow(2,n,10**9+7)-1-cmb(n,a,10**9+7)-cmb(n,b,10**9+7))\nif v >= 0:\n print(v)\nelse:\n print(v+10**9+7)', 'n,a,b = map(int,input().split())\ndef cmb(n, r, mod):\n x = 1 \n y = 1\n for i in range(r):\n x = x*(n-i)%(mod)\n for i in range(1,r+1):\n y = y*i%(mod)\n return x * pow(y,mod-2,mod) %mod\n\nv = int(pow(2,n,10**9+7)-1-cmb(n,a,10**9+7)-cmb(n,b,10**9+7))\nif v >= 0:\n print(v)\nelse:\n if v+10**9+7 >= 0:\n print(v+10**9+7)\n else:\n print(v+2*(10**9+7))']
['Wrong Answer', 'Time Limit Exceeded', 'Accepted']
['s560202298', 's807235593', 's645427998']
[199380.0, 224704.0, 3064.0]
[2106.0, 2118.0, 126.0]
[197, 602, 388]
p02768
u346308892
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\ndef II():\n return int(input())\n\ndirections=np.array([[1,0],[0,1],[-1,0],[0,-1]])\ndirections = list(map(np.array, directions))\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\ndef cmb2(n, r):\n if n - r < r:\n r = n - r\n if r == 0:\n return 1\n if r == 1:\n return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2, r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1, r, p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n\n return int(result)\n\n return count\n\n\ndef egcd(a, b):\n if a == 0:\n return b, 0, 1\n else:\n g, y, x = egcd(b % a, a)\n return g, x - (b // a) * y, y\n \ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception(\'modular inverse does not exist\')\n else:\n return x % m\n \ndef combination(n, r, mod=10**9+7):\n r = min(r, n-r)\n res = 1\n for i in range(r):\n res = res * (n - i) * modinv(i+1, mod) % mod\n return res\n\n\ndef modpow(a, n, mod):\n res = 1\n while n > 0:\n #print(n)\n\n if n & 1:\n res = res*a % mod\n a = a*a % mod\n #n >>= 1\n n>>=1\n\n return res\n\n\nn,a,b=acinput()\n\n\n\n\n#print(combination(n,a))\nc=combination(n,min(n,n-a))+combination(n,min(b,n-b))\n\n\n\nprint((modpow(2,n,mod)-c-1)%mod)\n', '\n\nfrom functools import *\nimport sys\nsys.setrecursionlimit(100000)\n\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\ndef II():\n return int(input())\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\ndef cmb2(n, r):\n if n - r < r:\n r = n - r\n if r == 0:\n return 1\n if r == 1:\n return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2, r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1, r, p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n\n return int(result)\n\n return count\n\n\ndef egcd(a, b):\n if a == 0:\n return b, 0, 1\n else:\n g, y, x = egcd(b % a, a)\n return g, x - (b // a) * y, y\n \ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception(\'modular inverse does not exist\')\n else:\n return x % m\n \ndef combination(n, r, mod=10**9+7):\n r = min(r, n-r)\n res = 1\n for i in range(r):\n res = res * (n - i) * modinv(i+1, mod) % mod\n return res\n\n\ndef modpow(a, n, mod):\n res = 1\n while n > 0:\n #print(n)\n\n if n & 1:\n res = res*a % mod\n a = a*a % mod\n #n >>= 1\n n>>=1\n\n return res\n\n\nn,a,b=acinput()\n\n\n\n\n#print(combination(n,a))\nc=combination(n,min(n,n-a))+combination(n,min(b,n-b))\n\n\n\nprint((modpow(2,n,mod)-c-1)%mod)\n']
['Runtime Error', 'Accepted']
['s892298953', 's079607434']
[3192.0, 3572.0]
[18.0, 1516.0]
[1709, 1682]
p02768
u361381049
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\nans = 2 ** n -1\nval = 1\nfor i in range(a):\n val *= (n-i) / (i+1)\nans -= val\nval = 1\nfor i in range(b):\n val *= (n-i) / (i+1)\nans -= val\nprint(int(ans % int(1e9) + 7))', 'n, a, b = map(int, input().split())\nm = int(1e9) + 7\nans = (pow(2, n, m) -1) % m\nval = 1\nval2 = 1\nfor i in range(a):\n val = (val * (n - i)) % m\n val2 = (val2 * (i + 1)) % m\nans -= (val * (pow(val2, m-2, m)))\n#print(((val % m) * (pow(val2, m-2, m))))\nval = 1\nval2 = 1\nfor i in range(b):\n val = (val * (n - i)) % m\n val2 = (val2 * (i + 1)) % m\nans -= val * (pow(val2, m-2, m))\n#print(((val % m) * (pow(val2, m-2, m))))\nprint(ans % m)']
['Runtime Error', 'Accepted']
['s579118463', 's110914630']
[199392.0, 3064.0]
[2108.0, 195.0]
[208, 443]
p02768
u370721525
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\nans = 0\n\nif n > 0:\n temp = 1\n for i in range(n):\n if i!=a and i!=b:\n temp = temp * (n-i) / (i+1)\n ans += temp\n \nans = ans % (10**9+7)\nprint(ans)', 'import math\nn, a, b = map(int, input().split())\nmod = 10**9 + 7\n\nans = pow(2, n, mod) - 1\n\nx = 1\ny = 1\nfor i in range(a):\n x = x*(n - i)%mod\n y = y*(i + 1)%mod\nans -= x*pow(y, mod - 2, mod)%mod\n \nx = 1\ny = 1\nfor i in range(b):\n x = x*(n - i)%mod\n y = y*(i + 1)%mod\nans -= x*pow(y, mod - 2, mod)%mod\n \nprint(ans%mod)\n']
['Wrong Answer', 'Accepted']
['s448948993', 's222866986']
[9168.0, 9208.0]
[2206.0, 178.0]
[200, 322]
p02768
u371763408
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int,input().split())\nmod = 10**9+7\ntotal = pow(2, n, mod) - 1\nprint(total)\ndef c(n, r):\n p, q = 1, 1\n for i in range(r):\n p *= (n-i)%mod\n q *= (i+1)%mod\n return p * pow(q, mod-2, mod)%mod\n\nprint((total - c(n, a) - c(n, b))%mod)', 'n, a, b = map(int,input().split())\nmod = 10**9+7\ntotal = pow(2, n, mod) - 1\ndef c(n, r):\n p, q = 1, 1\n for i in range(r):\n p = p*(n-i)%mod\n q = q*(i+1)%mod\n return p * pow(q, mod-2, mod)%mod\n\nprint((total - c(n, a) - c(n, b))%mod)']
['Wrong Answer', 'Accepted']
['s952338062', 's759723088']
[3604.0, 3064.0]
[2104.0, 150.0]
[264, 253]
p02768
u374082254
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\n\nmmod = 10**9 + 7\n\n\ndef comb_mod(n, r, mod=mmod):\n nume = 1\n deno = 1\n\n r = min(r, r - 1)\n\n for i in range(1, r + 1):\n nume = (nume * (n + 1 - i)) % mod\n deno = (deno * i) % mod\n\n return (nume * pow(deno, mod - 2, mod)) % mod\n\n\nif n == 2:\n print(0)\n exit\n\ntotal = (pow(2, n, mmod) - comb_mod(n, a) - comb_mod(n, b) - 1) % mmod\n\nprint(total)\n', 'n, a, b = map(int, input().split())\n\nmmod = 10**9 + 7\n\n\ndef comb_mod(n, r, mod=mmod):\n nume = 1\n deno = 1\n\n r = min(r, r - 1)\n\n for i in range(1, r + 1):\n nume = (nume * (n - i)) % mod\n deno = (deno * (i + 1)) % mod\n\n return (nume * pow(deno, mod - 2, mod)) % mod\n\n\nif n == 2:\n print(0)\n exit\n\ntotal = (pow(2, n, mmod) - comb_mod(n, a) - comb_mod(n, b) - 1) % mmod\n\nprint(total)\n', 'n, a, b = map(int, input().split())\n\nmmod = 10**9 + 7\n\n\ndef comb_mod(n, r, mod=mmod):\n nume = 1\n deno = 1\n\n r = min(r, n - r)\n\n for i in range(1, r + 1):\n nume = (nume * (n + 1 - i)) % mod\n deno = (deno * i) % mod\n\n return (nume * pow(deno, mod - 2, mod)) % mod\n\n\nresult_a = comb_mod(n, a)\nresult_b = comb_mod(n, b)\ntotal = (pow(2, n, mmod) - result_a - result_b - 1) % mmod\n\nprint(total)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s264058823', 's722775902', 's432680592']
[3064.0, 3064.0, 3064.0]
[141.0, 144.0, 141.0]
[412, 414, 418]
p02768
u382407432
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from functools import reduce\ndef cmb(n,r):\n numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])\n denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])\n return numerator * pow(denominator, mod - 2, mod) % mod\n\nans=0\nn,a,b = map(int,(input().split()))\n\n# ans=imp_pow(2,n)-1\nans=pow(2,c,10**9+7)-1\nans-=cmb(n,a)\nans-=cmb(n,b)\nprint(ans%10**9+7)', 'from functools import reduce\ndef cmb(n,r):\n numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])\n denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])\n return numerator * pow(denominator, mod - 2, mod) % mod\n\nans=0\nc,a,b = map(int,(input().split()))\n\n# ans=imp_pow(2,n)-1\nans=pow(2,c,10**9+7)-1\nans-=cmb(c,a)\nans-=cmb(c,b)\nprint(ans%10**9+7)', 'from functools import reduce\ndef cmb(r):\n numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])\n denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])\n return numerator * pow(denominator, mod - 2, mod) % mod\nn,a,b = map(int,(input().split()))\nans=0\nmod=10**9+7\n\nans=pow(2,n,10**9+7)-1\nans-=cmb(a)\nans-=cmb(b)\nprint(ans%mod)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s518553977', 's715094022', 's828313881']
[3572.0, 11556.0, 11556.0]
[24.0, 50.0, 233.0]
[398, 398, 378]
p02768
u385244248
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import sys\nimport math\nimport fractions\nimport itertools\nfrom collections import deque\nimport copy\nimport bisect\n\nMOD = 10 ** 9 + 7\nINF = 10 ** 18 + 7\ninput = lambda: sys.stdin.readline().strip()\n\n\ndef inv_mod(a, N):\n \n\n def extgcd(a, b):\n \n d = fractions.gcd(a, b)\n if b == 0:\n return 1, 0, a\n else:\n q, r = divmod(a, b)\n x, y, d = extgcd(b, r)\n s, t = y, x - q * y\n return s, t, d\n\n return extgcd(a, N)[0]\n\n\ndef bpm(x, y, N):\n \n ans = 1\n x %= MOD\n digit = int((math.log2(y) // 1 + 1)) \n for i in range(digit):\n if (y >> i) & 1 == 1:\n ans *= x\n ans %= MOD\n x **= 2\n x %= MOD\n return ans\n\n\nn, a, b = map(int, input().split())\n\nnCa = 1\nnCb = 1\n\ninv_list = []\n\nfor i in range(max(a, b)):\n inv_list.append(inv_mod(i + 1, MOD))\n\nfor i in range(a):\n nCa *= inv_list[i]\n nCa %= MOD\n nCa *= n - i\n nCa %= MOD\n\nfor i in range(b):\n nCb *= inv_list[i]\n nCb %= MOD\n nCb *= n - i\n nCb %= MOD\n\nprint((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)\n', 'import sys\nimport math\nimport fractions\nimport itertools\nfrom collections import deque\nimport copy\nimport bisect\n\nMOD = 10 ** 9 + 7\nINF = 10 ** 18 + 7\ninput = lambda: sys.stdin.readline().strip()\n\n\ndef inv_mod(a, N):\n \n\n def bpm(x, y, N):\n \n ans = 1\n x %= MOD\n digit = int((math.log(y, 2) // 1 + 1)) \n for i in range(digit):\n if (y >> i) & 1 == 1:\n ans *= x\n ans %= MOD\n x **= 2\n x %= MOD\n return ans\n\n return bpm(a, N - 2, N)\n\n\ndef bpm(x, y, N):\n \n ans = 1\n x %= MOD\n digit = int((math.log(y, 2) // 1 + 1)) \n for i in range(digit):\n if (y >> i) & 1 == 1:\n ans *= x\n ans %= MOD\n x **= 2\n x %= MOD\n return ans\n\n\nn, a, b = map(int, input().split())\n\nnCa = 1\nnCb = 1\n\ninv_list = [1] \nfor i in range(max(a, b)):\n inv_list.append(int(MOD - inv_list[(MOD % (i + 2)) - 1] * (MOD // (i + 2)) % MOD))\n\nfor i in range(a):\n nCa *= inv_list[i]\n nCa %= MOD\n nCa *= n - i\n nCa %= MOD\n\nfor i in range(b):\n nCb *= inv_list[i]\n nCb %= MOD\n nCb *= n - i\n nCb %= MOD\n\nprint((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)\n']
['Time Limit Exceeded', 'Accepted']
['s854012115', 's536636495']
[11732.0, 13116.0]
[2104.0, 359.0]
[1475, 1697]
p02768
u409542115
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['mod = (10 ** 9 + 7)\n\ndef comb(n, r):\n p, q = 1, 1\n\n for i in range(r):\n p = p *(n-i)%mod\n q = q *(i+1)%mod\n\n return (p / q) % mod\n\nn, a, b = list(map(int, input().split()))\n\ns = pow(2, n, mod) - 1\n\nprint((s - comb(n, a) - comb(n, b)) % mod)', '\nmod = (10 ** 9 + 7)\n\ndef comb(n, r):\n p, q = 1, 1\n\n for i in range(r):\n p = p *(n-i)%mod\n q = q *(i+1)%mod\n \n return p * pow(q, mod-2, mod) % mod\n\n\nn, a, b = list(map(int, input().split()))\n\ns = pow(2, n, mod) - 1\n\nprint((s - comb(n, a) - comb(n, b)) % mod)']
['Wrong Answer', 'Accepted']
['s489583394', 's024320312']
[3188.0, 3064.0]
[153.0, 149.0]
[263, 284]
p02768
u417365712
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def cmb(n, r, mod):\n c=1\n for i in range(1, r+1):\n c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod\n return c\n\nn, a, b = map(int, inputs[0]().split())\nMOD = 10**9 + 7\nprint((pow(2, n, MOD) - cmb(n, a, MOD) - cmb(n, b, MOD) - 1) % MOD)', "class Factorial():\n def __init__(self, mod=10**9 + 7):\n self.mod = mod\n self._factorial = [1]\n self._size = 1\n self._factorial_inv = [1]\n self._size_inv = 1\n\n def __call__(self, n):\n return self.fact(n)\n\n def fact(self, n):\n ''' n! % mod '''\n if n >= self.mod:\n return 0\n self._make(n)\n return self._factorial[n]\n \n def _make(self, n):\n if n >= self.mod:\n n = self.mod\n if self._size < n+1:\n for i in range(self._size, n+1):\n self._factorial.append(self._factorial[i-1]*i % self.mod)\n self._size = n+1\n\n def fact_inv(self, n):\n ''' n!^-1 % mod '''\n if n >= self.mod:\n raise ValueError('Modinv is not exist! arg={}'.format(n))\n self._make(n)\n if self._size_inv < n+1:\n self._factorial_inv += [-1] * (n+1-self._size_inv)\n self._size_inv = n+1\n if self._factorial_inv[n] == -1:\n self._factorial_inv[n] = self.modinv(self._factorial[n])\n return self._factorial_inv[n]\n \n @staticmethod\n def xgcd(a, b):\n '''\n Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)\n '''\n x0, x1, y0, y1 = 0, 1, 1, 0\n while a != 0:\n (q, a), b = divmod(b, a), a\n y0, y1 = y1, y0 - q * y1\n x0, x1 = x1, x0 - q * x1\n return b, x0, y0\n\n def modinv(self, n):\n g, x, _ = self.xgcd(n, self.mod)\n if g != 1:\n raise ValueError('Modinv is not exist! arg={}'.format(n))\n return x % self.mod\n\n def comb(self, n, r):\n ''' nCr % mod '''\n if r > n:\n return 0\n t = self(n)*self.fact_inv(n-r) % self.mod\n return t*self.fact_inv(r) % self.mod\n \n def comb_(self, n, r):\n '''\n nCr % mod\n when r is not large and n is too large\n '''\n c = 1\n for i in range(1, r+1):\n c *= (n-i+1) * self.fact_inv(i)\n c %= self.mod\n return c\n\n def comb_with_repetition(self, n, r):\n ''' nHr % mod '''\n t = self(n+r-1)*self.fact_inv(n-1) % self.mod\n return t*self.fact_inv(r) % self.mod\n\n def perm(self, n, r):\n ''' nPr % mod '''\n if r > n:\n return 0\n return self(n)*self.fact_inv(n-r) % self.mod\n\nmod = 10**9 + 7\nn, a, b = map(int, input().split())\ncomb = Factorial().comb_\nprint((pow(2, n, mod) - comb(n, a) - comb(n, b) - 1) % mod)", "class Factorial():\n def __init__(self, mod=10**9 + 7):\n self.mod = mod\n self._factorial = [1]\n self._size = 1\n self._factorial_inv = [1]\n self._size_inv = 1\n\n def __call__(self, n):\n return self.fact(n)\n\n def fact(self, n):\n ''' n! % mod '''\n if n >= self.mod:\n return 0\n self._make(n)\n return self._factorial[n]\n \n def _make(self, n):\n if n >= self.mod:\n n = self.mod\n if self._size < n+1:\n for i in range(self._size, n+1):\n self._factorial.append(self._factorial[i-1]*i % self.mod)\n self._size = n+1\n\n def fact_inv(self, n):\n ''' n!^-1 % mod '''\n if n >= self.mod:\n raise ValueError('Modinv is not exist! arg={}'.format(n))\n self._make(n)\n if self._size_inv < n+1:\n self._factorial_inv += [-1] * (n+1-self._size_inv)\n self._size_inv = n+1\n if self._factorial_inv[n] == -1:\n self._factorial_inv[n] = self.modinv(self._factorial[n])\n return self._factorial_inv[n]\n \n @staticmethod\n def xgcd(a, b):\n '''\n Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)\n '''\n x0, x1, y0, y1 = 0, 1, 1, 0\n while a != 0:\n (q, a), b = divmod(b, a), a\n y0, y1 = y1, y0 - q * y1\n x0, x1 = x1, x0 - q * x1\n return b, x0, y0\n\n def modinv(self, n):\n g, x, _ = self.xgcd(n, self.mod)\n if g != 1:\n raise ValueError('Modinv is not exist! arg={}'.format(n))\n return x % self.mod\n\n def comb(self, n, r):\n ''' nCr % mod '''\n if r > n:\n return 0\n t = self(n)*self.fact_inv(n-r) % self.mod\n return t*self.fact_inv(r) % self.mod\n \n def comb_(self, n, r):\n '''\n nCr % mod\n when r is not large and n is too large\n '''\n c = 1\n for i in range(1, r+1):\n c *= (n-i+1) * self.modinv(i)\n c %= self.mod\n return c\n\n def comb_with_repetition(self, n, r):\n ''' nHr % mod '''\n t = self(n+r-1)*self.fact_inv(n-1) % self.mod\n return t*self.fact_inv(r) % self.mod\n\n def perm(self, n, r):\n ''' nPr % mod '''\n if r > n:\n return 0\n return self(n)*self.fact_inv(n-r) % self.mod\n\nmod = 10**9 + 7\nn, a, b = map(int, input().split())\ncomb = Factorial().comb_\nprint((pow(2, n, mod) - comb(n, a) - comb(n, b) - 1) % mod)"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s357672678', 's587861530', 's819501585']
[3060.0, 24596.0, 9292.0]
[17.0, 1242.0, 1122.0]
[246, 2515, 2513]
p02768
u426649993
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def modpow(a, n, p):\n if n == 0:\n return 1\n elif n == 1:\n return a % p\n if n % 2 == 1:\n return (a * modpow(a, n-1, p)) % p\n tmp = modpow(a, n//2, p)\n return (tmp * tmp) % p\n\n\ndef modfactrial(a, p):\n ret = 1\n for i in (a, 1, -1):\n ret = ret * i % p\n return ret\n\n\ndef main():\n mod = 10 ** 9 + 7\n n, a, b = map(int, input().split())\n\n \n \n\n ans = (modpow(2, n, mod) - 1) % mod\n\n \n c_a = 1\n for i in range(n, n-a, -1):\n c_a *= i\n c_a %= mod\n c_a *= modpow(modfactrial(a, mod), mod-2, mod)\n ans -= c_a\n ans %= mod\n\n \n c_b = 1\n for i in range(n, n-b, -1):\n c_b *= i\n c_b %= mod\n c_b *= modpow(modfactrial(b, mod), mod-2, mod)\n ans -= c_b\n ans %= mod\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n', 'def modpow(a, n, p):\n if n == 0:\n return 1\n elif n == 1:\n return a % p\n if n % 2 == 1:\n return (a * modpow(a, n-1, p)) % p\n tmp = modpow(a, n//2, p)\n return (tmp * tmp) % p\n\n\ndef modfactrial(a, p):\n ret = 1\n for i in range(a, 1, -1):\n ret = ret * i % p\n return ret\n\n\ndef main():\n mod = 10 ** 9 + 7\n n, a, b = map(int, input().split())\n\n \n \n\n ans = (modpow(2, n, mod) - 1) % mod\n\n \n c_a = 1\n for i in range(n, n-a, -1):\n c_a *= i\n c_a %= mod\n c_a *= modpow(modfactrial(a, mod), mod-2, mod)\n ans -= c_a\n ans %= mod\n\n \n c_b = 1\n for i in range(n, n-b, -1):\n c_b *= i\n c_b %= mod\n c_b *= modpow(modfactrial(b, mod), mod-2, mod)\n ans -= c_b\n ans %= mod\n\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Accepted']
['s278518816', 's077627241']
[3064.0, 3064.0]
[81.0, 127.0]
[1073, 1078]
p02768
u428316812
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = list(map(int,input().split()))\nmod = 10**9 + 7\nans = (pow(2,n,mod) - 1\nnumerator = 1\ndenominator = 1\n\nfor i in range(1,n+1):\n numerator = (numerator*(n-i+1))%mod\n denominator = (denominator*i)%mod\n if i == a or i == b:\n ans = ans - (numerator*pow(denominator,mod-2,mod))%mod\n if i == b:\n break\n\nprint(ans%mod)', 'n,a,b = list(map(int,input().split()))\nmod = 10**9 + 7\nans = pow(2,n,mod) - 1\nnumerator = 1\ndenominator = 1\n\nfor i in range(1,n+1):\n numerator = (numerator*(n-i+1))%mod\n denominator = (denominator*i)%mod\n if i == a or i == b:\n ans = ans - (numerator*pow(denominator,mod-2,mod))%mod\n if i == b:\n break\n\nprint(ans%mod)']
['Runtime Error', 'Accepted']
['s634448912', 's785487165']
[2940.0, 3064.0]
[17.0, 119.0]
[351, 350]
p02768
u437215432
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['# ABC156D\n\nimport numpy as np\ndef f(n, x):\n mean = np.mean(x)\n s1 = sum((x-np.floor(mean))**2)\n s2 = sum((x-np.ceil(mean))**2)\n print(int(min(s1, s2)))\n\nn = int(input())\nx = list(map(int, input().split()))\nf(n, x)\n', 'from functools import reduce\ndef comb(n, r, mod=10 ** 9 + 7):\n numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])\n denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])\n return numerator * pow(denominator, mod - 2, mod) % mod\n\nn, a, b = map(int, input().split())\nmod = 1000000007\nprint((pow(2, n, mod) - 1 - comb(n, a, mod) - comb(n, b, mod)) % mod)\n']
['Runtime Error', 'Accepted']
['s330368005', 's105059686']
[27048.0, 11556.0]
[107.0, 226.0]
[227, 408]
p02768
u440161695
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['mod=10**9+7\nl,a,b=map(int,input().split())\ndef C(n,k,m):\n for i in range(1,k):\n n*=(n-i)%m\n k*=(k-i)%m\n return n*pow(k,m-2,m)\n\nans=pow(2,l,mod)\nca=C(l,a,mod)\nprint(ca)\ncb=C(l,b,mod)\nprint(cb)\nprint((ans-ca-cb)%mod)', 'mod=10**9+7\nl,a,b=map(int,input().split())\ndef C(n,k,m):\n g=k\n f=n\n for i in range(1,k):\n n=n*(f-i)%m\n k=k*(g-i)%m\n return (n*pow(k,m-2,m))%m\nans=pow(2,l,mod)-1\nca=C(l,a,mod)\ncb=C(l,b,mod)\nprint((ans-ca-cb)%mod)']
['Wrong Answer', 'Accepted']
['s259671981', 's258999534']
[3316.0, 3064.0]
[2104.0, 133.0]
[222, 221]
p02768
u442877951
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['mod = 10**9 + 7\ndef cmb(n,r,mod):\n\ta=1\n\tb=1\n\tr = min(r,n-r)\n\tfor i in range(r):\n\t\ta = a*(n-i)%mod\n\t\tb = b*(i+1)%mod\n\treturn a*pow(b,mod-2,mod)%mod\n\nn,a,b = map(int,input().split())\ncount = 0\nall = pow(2,n,mod) - 1\nnCa = cmb(n,a,mod)\nnCb = cmb(n,b,mod)\nans = all - (nCa + nCb) + mod\nprint(ans)', 'n,a,b = map(int,input().split())\ncount = 0\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n \n\nfor i in range(2, n + 1):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\nfor j in range(2,n + 1):\n if j == a or i == b:\n pass\n else:\n count += cmb(n, j, p)\nprint(count)\n', 'N,A,B = map(int,input().split())\n\nmod = 10**9 + 7\ndef cmb(n,r,mod):\n\ta=1\n\tb=1\n\tr = min(r,n-r)\n\tfor i in range(r):\n\t\ta = a*(n-i)%mod\n\t\tb = b*(i+1)%mod\n\treturn a*pow(b,mod-2,mod)%mod\n\nall = pow(2,N,mod) + mod\nnCa = cmb(N,A,mod)\nnCb = cmb(N,B,mod)\n\nans = all - nCa - nCb\nprint((ans-1)%mod)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s617419569', 's817122944', 's389382531']
[3064.0, 216772.0, 3064.0]
[142.0, 2121.0, 147.0]
[292, 591, 286]
p02768
u452512115
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def ncr(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\nN, a, b = map(int, input().split())\np = 10 ** 9 + 7\n"N = 10 ** 6 \nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n \nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\n \nal = 2**N -1\nacr = ncr(N, a, p)\nbcr = ncr(N, b, p)\nprint(al-acr-bcr)', 'mod = 7+10**9\ndef ncr(n,c,mod):\n x = 1\n y = 1\n for i in range(n-c+1,n+1):\n x = x*i%mod\n for j in range(1,c+1):\n y = y*j%mod\n return (x * pow(y, mod-2, mod)) % mod\n\nn, a, b = map(int, input().split())\nal = pow(2, n, mod) -1\nacr = ncr(n, a, mod)\nbcr = ncr(n, b, mod)\nprint((al-(acr+bcr))%mod', 'mod = 7+10**9\ndef ncr(n,c,mod):\n x = 1\n y = 1\n for i in range(n-c+1,n+1):\n x = x*i%mod\n for j in range(1,c+1):\n y = y*j%mod\n return (x * pow(y, mod-2, mod)) % mod\n\nn, a, b = map(int, input().split())\nal = pow(2, n, mod) -1\nacr = ncr(n, a, mod)\nbcr = ncr(n, b, mod)\nprint( (al-(acr+bcr))%mod )']
['Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s858931350', 's903936629', 's368691934']
[219660.0, 3064.0, 3064.0]
[2119.0, 17.0, 109.0]
[510, 300, 303]
p02768
u459798349
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['\nn,a,b=map(int,input().split())\nmod=10**9+7\n\n\nP = 10**9 + 7\nN = 200001\ninv_t = [0]+[1]\nfor i in range(2,N):\n inv_t += [inv_t[P % i] * (P - int(P / i)) % P]\n\ndef power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\n\ndef comb(x):\n res=1\n for i in range(n-x+1,n+1):\n res*=i\n res=res%mod\n for i in range(1,x+1):\n res*=inv_t[i]\n res=res%mod\n return res\n\nal=power_func(2,n,mod)\nprint((al-comb(a)-comb(b))%mod)', '\nn,a,b=map(int,input().split())\nmod=10**9+7\n\n\nP = 10**9 + 7\nN = 200001\ninv_t = [0]+[1]\nfor i in range(2,N):\n inv_t += [inv_t[P % i] * (P - int(P / i)) % P]\n\ndef power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\n\ndef comb(x):\n res=1\n for i in range(n-x+1,n+1):\n res*=i\n res=res%mod\n for i in range(1,x+1):\n res*=inv_t[i]\n res=res%mod\n return res\n\nal=power_func(2,n,mod)-1\nprint((al-comb(a)-comb(b))%mod)']
['Wrong Answer', 'Accepted']
['s294194520', 's235183045']
[11052.0, 11052.0]
[283.0, 308.0]
[557, 559]
p02768
u461454424
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['#input\nn, a, b = map(int, input().split())\n\n#output\nmod = 10**9 + 7\n\nn_ = 10**9 + 1\nfun = [1]*(n_+1)\nfor i in range(1,n_+1):\n fun[i] = fun[i-1]*i%mod\nrev = [1]*(n_+1)\nrev[n_] = pow(fun[n_],mod-2,mod)\nfor i in range(n_-1,0,-1):\n rev[i] = rev[i+1]*(i+1)%mod\ndef cmb(n,r):\n if n <= 0 or r < 0 or r > n: return 0\n return fun[n]*rev[r]%mod*rev[n-r]%mod\n\nanswer = 2**n - 1 - cmb(n, a) - cmb(n, b)\nprint(answer % mod)', '#input\nn, a, b = map(int, input().split())\n\n#output\nmod = pow(10, 9) + 7\n\nn_ = pow(10, 9) + 1\nfun = [1]*(n_+1)\nfor i in range(1,n_+1):\n fun[i] = fun[i-1]*i%mod\nrev = [1]*(n_+1)\nrev[n_] = pow(fun[n_],mod-2,mod)\nfor i in range(n_-1,0,-1):\n rev[i] = rev[i+1]*(i+1)%mod\ndef cmb(n,r):\n if n <= 0 or r < 0 or r > n: return 0\n return fun[n]*rev[r]%mod*rev[n-r]%mod\n\nanswer = pow(2, n) - 1 - cmb(n, a) - cmb(n, b)\nprint(answer % mod)', '#input\nn, a, b = map(int, input().split())\n\n#output\nmod = pow(10, 9) + 7\n\ndef cmb(n, k):\n numerator = 1\n denominator = 1\n\n for i in range(k):\n numerator *= n-i\n numerator %= mod\n denominator *= i+1\n denominator %= mod\n return numerator*pow(denominator, mod-2, mod) % mod\n\n\nanswer = pow(2, n, mod) - 1 - cmb(n, a) - cmb(n, b)\nprint(answer % mod)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s291343873', 's419621991', 's437512250']
[3064.0, 3064.0, 3064.0]
[17.0, 17.0, 156.0]
[422, 437, 384]
p02768
u476124554
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int,input().split())\n\n\nwa = pow(2, n, 10 ** 9 + 7) - 1\n\n\n#val1 = comb(n, a, exact=True)\n#val2 = comb(n, b, exact = True)\n\nx = 1\ny = 1\nfor i in range(a):\n x = (x * (n-i)) % (10 ** 9 + 7)\n y = (y * (i+1)) % (10 ** 9 + 7)\nval1 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)\n\nx = 1\ny = 1\nfor i in range(b):\n x = (x * (n-i)) % (10 ** 9 + 7)\n y = (y * (i+1)) % (10 ** 9 + 7)\n\nval2 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)\n\nans = wa - val1 - val2\nfor i in range(100):\nif ans < 0:\n ans += 10 ** 9 + 7\nprint(ans)', 'n,a,b = map(int,input().split())\n\n\nwa = pow(2, n, 10 ** 9 + 7) - 1\n\n\n#val1 = comb(n, a, exact=True)\n#val2 = comb(n, b, exact = True)\n\nx = 1\ny = 1\nfor i in range(a):\n x = (x * (n-i)) % (10 ** 9 + 7)\n y = (y * (i+1)) % (10 ** 9 + 7)\nval1 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)\n\nx = 1\ny = 1\nfor i in range(b):\n x = (x * (n-i)) % (10 ** 9 + 7)\n y = (y * (i+1)) % (10 ** 9 + 7)\n\nval2 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)\n\nans = wa - val1 - val2\nfor i in range(100):\n if ans < 0:\n ans += 10 ** 9 + 7\nprint(ans)']
['Runtime Error', 'Accepted']
['s769495449', 's742805631']
[3064.0, 3064.0]
[17.0, 170.0]
[633, 641]
p02768
u485979475
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from operator import mul\nfrom functools import reduce\n\nn,a,b=map(int,input().split())\n\nso=10**9+7\n\nlarge=(pow(2,n,so))\n\ndef kumiawase(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1)) % so\n under = reduce(mul, range(1,r + 1))\n \n return over * pow(under,so-2,so)\n\najogai = kumiawase(n,a) % so\nbjogai = kumiawase(n,b) % so\nprint((large - ajogai - bjogai + 2*so) % so)', 'from operator import mul\nfrom functools import reduce\nimport math\n\nn,a,b=map(int,input().split())\n\nso=10**9+7\n\nlarge=(pow(2,n,so))\n\ndef kumiawase(n,r):\n return math.fractorial(n) / (math.fractorial(n-r) * math.fractorial(r)\n\najogai = kumiawase(n,a) % so\nbjogai = kumiawase(n,b) % so\nprint((large - ajogai - bjogai + 2*so) % so)', 'from operator import mul\nfrom functools import reduce\nimport math\n\nn,a,b=map(int,input().split())\n\nso=10**9+7\n\nlarge=(pow(2,n,so))\n\ndef kumiawase(n,r):\n return int(math.factorial(n) / (math.factorial(n-r) * math.factorial(r)))\n\najogai = kumiawase(n,a) % so\nbjogai = kumiawase(n,b) % so\nprint(large)\nprint(ajogai)\nprint(bjogai)\nprint((large - 1 - ajogai - bjogai + 2*so) % so)', 'from operator import mul\nfrom functools import reduce\nimport math\n\nn,a,b=map(int,input().split())\n\nso=10**9+7\n\nlarge=(pow(2,n,so)-1)\n\ndef kumiawase(n,r):\n over=1\n for i in range(r):\n over *= n-i\n over %= so\n under = math.factorial(r)\n return over * pow(under,so-2,so)\n\najogai = kumiawase(n,a) % so\nbjogai = kumiawase(n,b) % so\nprint((large - ajogai - bjogai + 2*so) % so)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s221230266', 's360245905', 's687406910', 's819011270']
[4248.0, 2940.0, 8236.0, 6032.0]
[2107.0, 17.0, 2104.0, 1510.0]
[417, 330, 378, 397]
p02768
u490489966
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['#D\nn, a, b = map(int, input().split())\nmod = pow(10, 9) + 7\n\n\ndef comb(n, x):\n numerator = 1\n for i in range(n, n - x, -1):\n numerator = numerator * i % mod\n\n denominator = 1\n for j in range(x, 1, -1):\n denominator = denominator * j % mod\n\n d = denominator ** mod - 2 % mod\n\n return numerator * d\n\n# #pow\n# # def pow(x, n, mod=10e9+7):\n# # ans = 1\n# # while (n > 0):\n# # if bin(n & 1) == bin(1):\n# # ans *= x\n# # x *= x\n# # n = n >> 1\n# # return ans\n\na = comb(n, a)\nb = comb(n, b)\n\nprint((2**n %mod - 1 - a - b) % mod)\n', '#D\nn, a, b = map(int, input().split())\nmod = pow(10, 9) + 7\n\ndef comb(n, x):\n numerator = 1\n for i in range(n, n - x, -1):\n numerator = numerator * i % mod\n\n denominator = 1\n for j in range(x, 1, -1):\n denominator = denominator * j % mod\n\n d = pow(denominator, mod-2, mod)\n\n return numerator * d\n\na = comb(n, a)\nb = comb(n, b)\n\nprint((pow(2, n, mod) - 1 - a - b) % mod)']
['Time Limit Exceeded', 'Accepted']
['s538955255', 's045096824']
[165772.0, 3064.0]
[2108.0, 119.0]
[599, 401]
p02768
u497952650
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def combination(n,r,mod=10**9+7):\n n1 = n+1\n r = min(r,n-r)\n numer = denom = 1\n for i in range(1,r+1):\n numer = numer * (n1-i) % mod\n denom = denom * i % mod\n return numer * pow(denom,mod-2,mod) % mod\n \ndef power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\n \nmod = int(1e9+7)\nn,a,b= map(int,input().split())\n \nS = (pow(2,n,mod))%mod\nA = combination(n,a)\nB = combination(n,b)\nans = (S-A-B)%mod\n \nprint(ans)', 'def combination(n,r,mod=10**9+7):\n n1 = n+1\n r = min(r,n-r)\n numer = denom = 1\n for i in range(1,r+1):\n numer = numer * (n1-i) % mod\n denom = denom * i % mod\n return numer * pow(denom,mod-2,mod) % mod\n \nmod = int(1e9+7)\nn,a,b= map(int,input().split())\n \nS = (pow(2,n,mod) - 1)%mod\nA = combination(n,a)\nB = combination(n,b)\nans = (S-A-B)%mod\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s009142038', 's811478436']
[3064.0, 3064.0]
[132.0, 130.0]
[572, 382]
p02768
u506858457
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from scipy.misc import comb\nN,a,b=map(int,input().split())\nMOD=10**9+7\ncnt=0\nfor i in range(1,N+1):\n cnt+=comb(N, i, exact=True)\nA=comb(N, a, exact=True)\nB=comb(N, b, exact=True)\ncnt=cnt-A-B\nans=cnt%MOD\nprint(ans)', 'def MI(): return map(int, input().split())\nMOD=10**9+7\ndef nCr(n,k):\n tmp=1\n for i in range(n-k+1,n+1):\n tmp*=i\n tmp%=MOD\n for i in range(1,k+1):\n tmp*=pow(i,MOD-2,MOD)\n tmp%=MOD\n return tmp\nN,A,B=MI()\nans=pow(2,N,MOD)-1-nCr(N,A)-nCr(N,B)\nprint(ans%MOD)']
['Time Limit Exceeded', 'Accepted']
['s779004912', 's724608456']
[15276.0, 9204.0]
[2112.0, 1218.0]
[214, 269]
p02768
u507613674
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from collections import defaultdict\nfrom collections import deque\nfrom string import ascii_uppercase\nimport sys, bisect, math, heapq\n\nstdin = sys.stdin\nread_int = lambda : list(map(int,stdin.readline().split()))\nread_str = lambda : stdin.readline().rstrip()\n\nn, a, b = read_int()\nM = pow(10, 9) + 7\n\ncomk = [1 for _ in range(b + 2)]\ndef solve():\n ans = 0\n for i in range(1, b + 2):\n comk[i] = (comk[i - 1] * ((n - i + 1)) / i) % M\n ans = (pow(2, n, M) - 1) - (comk[a]+ comk[b]) % M\n return ans % M\n\n\nif __name__ == "__main__":\n print(solve())', 'import sys, math\n\nstdin = sys.stdin\nread_int = lambda : list(map(int,stdin.readline().split()))\n\nn, a, b = read_int()\nM = pow(10, 9) + 7\ncomk = [1 for _ in range(b + 2)]\n\ndef solve():\n ans = 0\n for i in range(1, b + 1):\n print(i)\n comk[i] = (comk[i - 1] * ((n - i + 1)) / i)\n ans = (pow(2, n, M) - 1) - ((comk[a] + comk[b]) % M)\n return ans % M\n\nif __name__ == "__main__":\n print(solve())', 'import sys, math\n\nstdin = sys.stdin\nread_int = lambda : list(map(int,stdin.readline().split()))\n\nn, a, b = read_int()\nM = pow(10, 9) + 7\ncomk = [1 for _ in range(b + 2)]\n\ndef solve():\n ans = 0\n for i in range(1, b + 1):\n comk[i] = (comk[i - 1] * ((n - i + 1)) / i)\n ans = (pow(2, n, M) - 1) - ((comk[a] + comk[b]) % M)\n return ans % M\n\nif __name__ == "__main__":\n print(solve())\n', 'import sys, math\n\nstdin = sys.stdin\nread_int = lambda : list(map(int,stdin.readline().split()))\n\nn, a, b = read_int()\nM = pow(10, 9) + 7\nsys.setrecursionlimit(300000)\n\ndef solve():\n ans = (pow(2, n, M) - 1) - kai(n, 0, a) * pow(kai(a, 0, a), M - 2, M) - kai(n, 0, b) * pow(kai(b, 0, b), M - 2, M)\n return ans % M\n\ndef kai(n, i, m):\n if i == m:\n return 1\n return (n * kai(n - 1, i + 1, m)) % M\n\nif __name__ == "__main__":\n print(solve())\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s448269899', 's705503676', 's976723914', 's438661245']
[9976.0, 10864.0, 9368.0, 181236.0]
[132.0, 245.0, 107.0, 888.0]
[565, 418, 402, 459]
p02768
u519078363
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def modinv(a, mod=10**9+7):\n return pow(a, mod-2, mod)\n\ndef comb(n, r, mod=10**9+7):\n r = min(r, n-r)\n res = 1\n for i in range(r):\n res = res * (n - i) * modinv(i+1, mod) % mod\n return res\n\nn, a, b = list(map(int, input().split()))\n# print(int((2 ** n % (10**9+7)) - 1 - comb(n, a) - comb(n, b)))\nprint(int((pow(2, n, 10**9+7) - 1 - comb(n, a, 10**9+7) - comb(n, b, 10**9+7))) % 10**9+7)', 'def modinv(a, mod=10**9+7):\n return pow(a, mod-2, mod)\n\ndef comb(n, r, mod=10**9+7):\n r = min(r, n-r)\n res = 1\n for i in range(r):\n res = res * (n - i) * modinv(i+1, mod) % mod\n return res\n\nn, a, b = list(map(int, input().split()))\nmod = 10**9+7\nprint(int(pow(2, n, mod) - 1 - comb(n, a, mod) - comb(n, b, mod)) % mod)']
['Wrong Answer', 'Accepted']
['s432264476', 's536403792']
[3064.0, 3064.0]
[1550.0, 1551.0]
[409, 340]
p02768
u532966492
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def main():\n import numpy as np\n n, a, b = map(int, input().split())\n mod = 10**9+7\n\n def cumprod(vector, mod=10**9+7):\n a, n = np.array(vector, dtype=np.int64), len(vector)\n nsq = int((n-1)**0.5)+1\n a.resize(nsq, nsq)\n for i in range(1, nsq):\n a[:, i] *= a[:, i-1]\n a[:, i] %= mod\n for i in range(1, nsq):\n a[i] *= a[i-1, -1]\n a[i] %= mod\n a.resize(n)\n return a\n\n xx = cumprod([i for i in range(n, n-200001, -1)])\n yy = cumprod([i for i in range(200001)])\n\n ans1 = xx[a]*pow(int(yy[a]), mod-2, mod)\n ans2 = xx[b]*pow(int(yy[b]), mod-2, mod)\n\n print((pow(2, n, mod)-ans1-ans2-1) % mod)\n\n\nmain()\n', 'def main():\n n, a, b = map(int, input().split())\n mod = 10**9+7\n\n nn = n\n ans1 = 1\n while a > 0:\n ans1 = (ans1 * n * pow(a, mod-2, mod)) % mod\n n -= 1\n a -= 1\n\n ans2 = 1\n n = nn\n while b > 0:\n ans2 = (ans2 * n * pow(b, mod-2, mod)) % mod\n n -= 1\n b -= 1\n\n print((pow(2, nn, mod)-ans1-ans2-1) % mod)\n\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s731317514', 's079312630']
[26088.0, 3064.0]
[268.0, 1506.0]
[715, 377]
p02768
u545666277
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['# -*- coding: utf-8 -*-\n \nimport math\nimport itertools\nimport sys\nimport copy\n#import numpy as np\n \n\n#A, B, C, D = map(int, input().split())\n#L = list(map(int, input().split()))\n#S = list(str(input()))\n#N = int(input())\n#S = str(input())\n \nMOD = pow(10, 9) + 7\nn, a, b = map(int, input().split())\n\n# (2^n - nCa - nCb) mod MOD\n# = ( (2^n - 1 mod MOD) - (nCa mod MOD) - (nCb mod MOD ) ) mod MOD\n\n\na = min(a, n-a)\nb = min(b, n-b)\nrMAX = max(a, b)\n\n\n# (nCr mod MOD) = ( n*(n-1)*...*(n-r+1) * (a!)^-1 ) mod MOD\n# = ( (n mod MOD) * ((n-1) mod MOD) * ... * ((n-r+1) mod MOD) * (a!)^(MOD-2) ) mod MOD\n# (nCr mod MOD) = ( n! * (r!)^(-1) * ((n-r)!)^(-1)) mod MOD\n# = ( (n! mod MOD) * ((r!)^(MOD-2)) * ((n-r)!)^(MOD-2)) mod MOD\n#def nCr_mod(n, r, mod) :\n# r = n\n\n\n\n\n\n#ans = ( pow(2, n, MOD) - ()%MOD - ()%MOD ) % MOD\n\nn = pow(10, 5)\n#n = 10\n#MOD = 11\nfac = [0 for _ in range(n+1)]\n\nfac[0] = 1\nfac[1] = 1\nfor i in range(2, n+1) :\n fac[i] = (fac[i-1] * i) % MOD\n \nprint (1)\n\n', '# -*- coding: utf-8 -*-\n \nimport math\nimport itertools\nimport sys\nimport copy\n#import numpy as np\n \n\n#A, B, C, D = map(int, input().split())\n#L = list(map(int, input().split()))\n#S = list(str(input()))\n#N = int(input())\n#S = str(input())\n \nMOD = pow(10, 9) + 7\nn, a, b = map(int, input().split())\n \n# (2^n -1 - nCa - nCb) mod MOD\n# = ( (2^n - 1 mod MOD) - (nCa mod MOD) - (nCb mod MOD ) ) mod MOD\n# (nCr mod MOD) = ( n*(n-1)*...*(n-r+1) * (a!)^-1 ) mod MOD\n# = ( (n mod MOD) * ((n-1) mod MOD) * ... * ((n-r+1) mod MOD) * (r!)^(MOD-2) ) mod MOD\n\na = min(a, n-a)\nb = min(b, n-b)\nrMAX = max(a, b)\n\n\nnCr_Mol_ModList = [1 for _ in range(rMAX+1)]\n\nfac_ModList = [1 for _ in range(rMAX+1)]\n\nnCr_Mol_ModList[1] = n % MOD\nfac_ModList[1] = 1 % MOD\n\nfor i in range(2, rMAX+1) :\n nCr_Mol_ModList[i] = (nCr_Mol_ModList[i-1] * (n-i+1)) % MOD\n fac_ModList[i] = (fac_ModList[i-1] * i) % MOD\n\n#(2^n - 1 mod MOD) = X\n#(nCa mod MOD) = Y\n\n\nX = pow(2,n,MOD)-1%MOD\nY = ( nCr_Mol_ModList[a] * pow(fac_ModList[a], MOD-2, MOD) )%MOD\nZ = ( nCr_Mol_ModList[b] * pow(fac_ModList[b], MOD-2, MOD) )%MOD\n\nans = (X - Y - Z) % MOD\nprint (ans)\n']
['Wrong Answer', 'Accepted']
['s685155920', 's640531526']
[7540.0, 19444.0]
[62.0, 185.0]
[1023, 1197]
p02768
u547608423
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import math\nn,a,b=map(int,input().split())\n\ncount=0\n\ndef C(n,a):\n x=1\n y=1\n for i in range(a):\n x*=n-i\n y*=i+1\n return x/y\n\ncount+=pow(2,n-1)\ncount-=1\ncount-=C(n,a)\ncount-=C(n,b)\n\nprint(count%(10**9+7))', 'import math\nn,a,b=map(int,input().split())\n\ncount=0\n\ndef C(n,a):\n x=1\n y=1\n for i in range(a):\n x*=n-i\n y*=i+1\n return x/y\n\ncount+=pow(2,n)\nprint(count)\ncount-=1\ncount-=C(n,a)\nprint(count)\ncount-=C(n,b)\n\nprint(count%(10**9+7))', 'import math\nn,a,b=map(int,input().split())\n\ncount=0\nmod=1000000007\n\ndef C(n,a):\n x=1\n y=1\n for i in range(a):\n x*=n-i\n y*=i+1\n x%=mod\n y%=mod\n return x*pow(y,mod-2,mod)%mod\n\ncount+=pow(2,n,mod)\n#print(count)\ncount-=1\ncount-=C(n,a)\n#print(count)\ncount-=C(n,b)\n\nprint(max(0,(count)%mod))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s177784283', 's903185846', 's462946599']
[200900.0, 199348.0, 3064.0]
[2107.0, 2106.0, 160.0]
[228, 252, 325]
p02768
u548545174
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\n\nimport math\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nMDO = 10 ** 9 + 7\n\ntotal = 2 ** n - 1\nans = total - combinations_count(n, a) - combinations_count(n, b)\nprint(ans % MOD)\n\n', 'from functools import reduce\n\ndef combinations_count_mod(n, r, m):\n num = reduce(lambda x, y: x * y % m, range(n, n - r, -1))\n den = reduce(lambda x, y: x * y % m, range(1, r + 1))\n return num * pow(den, m - 2, m) % m\n\nN, A, B = map(int, input().split())\n\nMOD = 10 ** 9 + 7\n \nanswer = pow(2, N, MOD) - 1 - combinations_count_mod(N, A, MOD) - combinations_count_mod(N, B, MOD)\nanswer %= MOD\nprint(answer)']
['Runtime Error', 'Accepted']
['s977995512', 's138206164']
[199348.0, 3572.0]
[2107.0, 157.0]
[279, 412]
p02768
u549278479
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def factorial_mod(a, M):\n ans = 1\n for i in range(a,1,-1):\n ans = (ans * i) % M\n return ans\ndef test(n, a, M):\n ans = 1\n for i in range(a):\n ans = (ans * (n-i)) % M\n return ans\ndef combination_mod(n,a,M):\n tmp = factorial_mod(a,M)\n tmp = pow(tmp, M-2, M)\n ans = test(n,a,M) * tmp % M\n return ans\ndef output(n,a,b):\n M = 10**9+7\n ans = (pow(2,n,M) - 1 - combination_mod(n,a,M) - combination_mod(n,b,M)) % M\n return ans\nn, a, b = map(int, input().split())\nprint(output(a,b,c))', 'def factorial_mod(a, M):\n # return a!(mod M)\n ans = 1\n for i in range(a,1,-1):\n ans = (ans * i) % M\n return ans\ndef test(n, a, M):\n \n ans = 1\n for i in range(a):\n ans = (ans * (n-i)) % M\n return ans\ndef combination_mod(n,a,M):\n # return nCa % M\n tmp = factorial_mod(a,M)\n tmp = pow(tmp, M-2, M)\n ans = test(n,a,M) * tmp % M\n return ans\ndef output(n,a,b):\n M = 10**9+7\n ans = (pow(2,n,M) - 1 - combination_mod(n,a,M) - combination_mod(n,b,M)) % M\n return ans\nn, a, b = map(int, input().split())\nprint(output(n,a,b))']
['Runtime Error', 'Accepted']
['s171972335', 's266002151']
[3064.0, 3064.0]
[17.0, 125.0]
[527, 603]
p02768
u555199741
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
["MOD = 1000000007\n\nn, a, b = map(int, input().split())\n\n# https://tex2e.github.io/blog/crypto/modular-mul-inverse\ndef xgcd(a, b):\n\tx0, y0, x1, y1 = 1, 0, 0, 1\n\twhile b != 0:\n\t\tq, a, b = a // b, b, a % b\n\t\tx0, x1 = x1, x0 - q * x1\n\t\ty0, y1 = y1, y0 - q * y1\n\treturn a, x0, y0\n\n# https://tex2e.github.io/blog/crypto/modular-mul-inverse\ndef modinv(a, m):\n\tg, x, y = xgcd(a, m)\n\tif g != 1:\n\t\traise Exception('modular inverse does not exist')\n\telse:\n\t\treturn x % m\n\ndef combination(n, r):\n\tans = 1\n\tfor i in range(n - r + 1, n + 1):\n\t\tans *= i\n\t\tans %= MOD\n\tfor i in range(1, r + 1):\n\t\tans *= modinv(i, MOD)\n\t\tans %= MOD\n\treturn ans\n\nans = 0\nans += pow(2, n, MOD)\n - 1\nans += MOD - combination(n, a)\nans += MOD - combination(n, b)\nans %= MOD\n\nprint(ans)\n", "MOD = 1000000007\n\nn, a, b = map(int, input().split())\n\n# https://tex2e.github.io/blog/crypto/modular-mul-inverse\ndef xgcd(a, b):\n\tx0, y0, x1, y1 = 1, 0, 0, 1\n\twhile b != 0:\n\t\tq, a, b = a // b, b, a % b\n\t\tx0, x1 = x1, x0 - q * x1\n\t\ty0, y1 = y1, y0 - q * y1\n\treturn a, x0, y0\n\n# https://tex2e.github.io/blog/crypto/modular-mul-inverse\ndef modinv(a, m):\n\tg, x, y = xgcd(a, m)\n\tif g != 1:\n\t\traise Exception('modular inverse does not exist')\n\telse:\n\t\treturn x % m\n\ndef combination(n, r):\n\tans = 1\n\tfor i in range(n - r + 1, n + 1):\n\t\tans *= i\n\t\tans %= MOD\n\tfor i in range(1, r + 1):\n\t\tans *= modinv(i, MOD)\n\t\tans %= MOD\n\treturn ans\n\nans = 0\nans += pow(2, n, MOD) - 1\nans += MOD - combination(n, a)\nans += MOD - combination(n, b)\nans %= MOD\n\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s969729801', 's111051552']
[3064.0, 3064.0]
[17.0, 1590.0]
[748, 747]
p02768
u555291433
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['#!/usr/bin/env python\n\nn, a, b = (int(val) for val in input().split())\n\n\nans = 1\nnoa = 1\nnob = 1\nmod = 1000000007\nkaijo = 1\nfor i in range(n):\n ans *= 2\n ans %= mod\n if i < a:\n noa *= (n - i)\n noa %= mod\n if i == a - 1:\n noa /= kaijo\n if i < b:\n kaijo *= i + 1\n kaijo %= mod\n nob *= (n - i)\n nob %= mod\n if i == b - 1:\n nob /= kaijo\nans -= 1\n\n# ans = ans - noa - nob\n# while ans < 0:\n# ans += mod\nprint((ans - noa - nob) % mod)\n', '#!/usr/bin/env python\n\n\ndef pow(m, n):\n if n == 0:\n return 1\n elif n % 2 == 0:\n return (pow(m, int(n / 2)) ** 2) % mod\n elif n % 2 == 1:\n return (pow(m, int((n - 1) * 0.5)) ** 2 * m) % mod\n\n\ndef conb(n, a):\n mod1 = 1\n mod2 = 1\n for i in range(a):\n mod1 *= n - i\n mod1 %= mod\n mod2 *= i + 1\n mod2 %= mod\n mod2 = pow(mod2, mod - 2)\n return (mod1 * mod2) % mod\n\n\nn, a, b = (int(val) for val in input().split())\n\n\nans = 1\nnoa = 1\nnob = 1\nmod = 1000000007\nans = pow(2, n) - 1 - conb(n, a) - conb(n, b)\nans %= mod\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s355927444', 's533238555']
[3064.0, 3188.0]
[2104.0, 157.0]
[506, 592]
p02768
u556751939
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\nnca = len(list(itertools.combinations(range(n), a)))\nncb = len(list(itertools.combinations(range(n), b)))\n# answer = 2**n - 1 - nca - ncb\n# print(answer % (10**9 + 7))\nprint((2**n - 1 - nca - ncb) % (10**9 + 7))\n', 'mod = int(1e9 + 7)\ndef cmb(n, r):\n if n - r < r: r = n - r\n if r == 0: return 1\n if r == 1: return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n result %= mod\n\n return result\n\n\nn, a, b = map(int, input().split())\n\nbase = 1\nwaru = 1000\nsyou = n // waru\namari = n % waru\nkakeru = 2**waru % mod\nfor _ in range(syou):\n base = base * kakeru\n base %= mod\nbase = base * 2**amari\nbase %= mod\n\nnca = cmb(n, a%mod)\nncb = cmb(n, b%mod)\nanswer = (base - 1 - nca - ncb) % mod\nprint(answer)\n']
['Runtime Error', 'Accepted']
['s373741623', 's568559913']
[2940.0, 27700.0]
[17.0, 1024.0]
[248, 908]
p02768
u572012241
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\nans = 1\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\npr1 = cmb(n,a,mod)\npr2 = cmb(n,b,mod)\nfor i in range(0,n):\n ans *= 2\n ans %= 1000000007\n\nprint(ans-pr1-pr2-1)', 'def pow(x, n , mod):\n res = 1\n while n > 0:\n if bin(n & 1) == bin(1) :\n res = res * x % mod\n x = x*x % mod\n n = n >>1\n return res \n\ndef combination(n,a):\n x = 1\n for i in range(a):\n x = x * (n-i) % mod\n y = 1\n for i in range(a):\n y = y * (a-i) % mod\n y = pow(y, mod-2, mod)\n return (x*y % mod)\nn, a, b = map(int, input().split())\nmod = 1000000007\nprint((pow(2,n,mod) - 1 - combination(n,a) - combination(n,b)) % mod)']
['Runtime Error', 'Accepted']
['s679897028', 's919101742']
[4340.0, 3064.0]
[29.0, 154.0]
[617, 492]
p02768
u580697892
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['# coding: utf-8\ndef modcomb(n, r, mod):\n "nCr = X/Yとおく"\n r = min(r, n - r)\n X, Y = 1, 1\n # a, b, c = 1, 1, 1\n for i in range(1, n + 1):\n X = X * (n + 1 - i) % mod\n Y = Y * i % mod\n a = a * i % mod\n for i in range(1, r + 1):\n b = b * i % mod\n c = c * (n - i + 1) % mod\n return a * pow((b * c) % mod, mod-2, mod) % mod\n \n\nN, A, B = map(int, input().split())\nmod = 10 ** 9 + 7\nans = pow(2, N, mod) - 1\na = modcomb(N, A, mod)\n# ans %= mod\nb = modcomb(N, B, mod)\nans -= a + b\nprint(ans % mod)', '# coding: utf-8\ndef modcomb(n, r, mod):\n "nCr = X/Yとおく"\n r = min(r, n - r)\n X, Y = 1, 1\n a, b, c = 1, 1, 1\n for i in range(1, n + 1):\n #X = X * (n + 1 - i) % mod\n \n a = a * i % mod\n b = b * i % mod\n for i in range(1, r + 1):\n c = c * (n - i + 1) % mod\n return a * pow((b * c) % mod, mod-2, mod) % mod\n \n\nN, A, B = map(int, input().split())\nmod = 10 ** 9 + 7\nans = pow(2, N, mod) - 1\na = modcomb(N, A, mod)\n# ans %= mod\nb = modcomb(N, B, mod)\nans -= a + b\nprint(ans % mod)\n', '# coding: utf-8\ndef modcomb(n, r, mod):\n "nCr = X/Yとおく"\n r = min(r, n - r)\n X, Y = 1, 1\n for i in range(1, r + 1):\n X = X * (n + 1 - i) % mod\n Y = Y * i % mod\n # return ue * modpow(sita, mod-2, mod)\n return X * pow(Y, mod-2, mod) % mod\n\nN, A, B = map(int, input().split())\nmod = 10 ** 9 + 7\nans = pow(2, N, mod) - 1\na = modcomb(N, A, mod)\n# ans %= mod\nb = modcomb(N, B, mod)\nans -= a + b\nprint(ans % mod)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s316367783', 's888301125', 's184087212']
[3064.0, 3064.0, 3064.0]
[20.0, 2104.0, 140.0]
[589, 590, 442]
p02768
u591143370
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
["import math\nfrom operator import mul\nfrom functools import reduce\nn, a, b = map(int, input().split())\ns=0\nmod = pow(10, 9) + 7\ndef combinations_count(n, r):\n #return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\nif n==2:\n print('0')\na=combinations_count(n, a)\n\nb=combinations_count(n, b)\nelse:\n print((pow(2, n, mod) -1 -a -b) % mod)", '\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\nn, a, b = map(int, input().split())\nmod = pow(10, 9) + 7\n \ndef comb(N, x):\n numerator = 1\n for i in range(N-x+1, N+1):\n numerator = numerator * i % mod\n denominator = 1\n for j in range(1, x+1):\n denominator = denominator * j % mod\n d = pow(denominator, mod-2, mod)\n return numerator * d\n \na = comb(n, a)\nb = comb(n, b)\n \nprint((pow(2, n, mod) -1 -a -b) % mod)']
['Runtime Error', 'Accepted']
['s602361559', 's926359920']
[3060.0, 3064.0]
[17.0, 116.0]
[501, 434]
p02768
u592035627
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['M,A,B = [int(x) for x in input().split()]\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 200000\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\n\ndef binary(n):\n return bin(n)[2:]\n\n\ndef pow_by_binary_exponentiation(a, x, n): \n x = [int(b) for b in binary(x)]\n y = a\n for i in range(1, len(x)):\n y = (y**2) % n\n if x[i] == 1:\n y = (y * a) % n\n return y\nd = pow_by_binary_exponentiation(2,M,mod)-1\n \nd1 = cmb(M,A,mod)\nd2 = cmb(M,B,mod)\nprint((d-d1-d2)%mod)', 'M,A,B = [int(x) for x in input().split()]\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**9\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n#a = cmb(n,r,mod)\nd = 0\nfor i in range(N):\n f = cmb(M,i+1,mod)\n d = d + f\n \nd1 = cmb(M,A,mod)\nd2 = cmb(M,B,mod)\nprint((d-d1-d2)%mod)\n', 'M,A,B = [int(x) for x in input().split()]\n\nmod = 10**9+7\n\ndef cmb(n, r, mod):\n r = min(r, n-r)\n res = 1\n for i in range(r):\n res = res * (n - i) % mod * pow(i+1, mod-2, mod) % mod\n return res\n\ndef binary(n):\n return bin(n)[2:]\n\n\ndef pow_by_binary_exponentiation(a, x, n): \n x = [int(b) for b in binary(x)]\n y = a\n for i in range(1, len(x)):\n y = (y**2) % n\n if x[i] == 1:\n y = (y * a) % n\n return y\nd = pow_by_binary_exponentiation(2,M,mod)-1\n \nd1 = cmb(M,A,mod)\nd2 = cmb(M,B,mod)\nprint((d-d1-d2)%mod)']
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s154900758', 's166537616', 's617555695']
[27092.0, 227132.0, 3064.0]
[275.0, 2118.0, 1528.0]
[866, 643, 574]
p02768
u595952233
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
["n, a, b = map(int, input().split())\nmod = 10**9+7\nans = pow(2, n, mod)-1\n\nmodp = mod \nmax_r = 10 ** 7 \nfactinv = [1, 1] + [0]*max_r # factinv[n] = ((n!)^(-1) mod modp)\ninv = [0, 1] + [0]*max_r \n\nfact = {}\n\ndef cmb(n, r, p):\n assert n < p, 'n is less than modp'\n assert r < max_r, 'n in less than max_n'\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n if (n, r) in fact:\n return fact[(n, r)] * factinv[r] % p\n else:\n f = 1\n for i in range(n, n-r, -1):\n f = f * i % p\n fact[(n, r)] = f\n return f * factinv[r] % p\n\nfor i in range(2, max_r + 1):\n inv[i] = (-inv[modp % i] * (modp // i)) % modp\n factinv[i] = (factinv[i-1] * inv[i]) % modp\n\nans-=cmb(n, a, mod)\nans-=cmb(n, b, mod)\nprint(ans%mod)\n", 'n, a, b = map(int, input().split())\nmod = 10**9+7\nans = pow(2, n, mod)-1\n\nmodp = mod\n\ndef cmb(n, r, p):\n r = min(r, n-r)\n upper = 1\n for i in range(n, n-r, -1):\n upper = (upper*i)%p\n \n lower = 1\n for i in range(1, r+1):\n lower = (lower*i)%p\n \n \n return (upper*pow(lower, p-2, p))%p\n\nans-=cmb(n, a, mod)\nans-=cmb(n, b, mod)\nprint(ans%mod)\n']
['Time Limit Exceeded', 'Accepted']
['s898352932', 's218861369']
[338572.0, 9196.0]
[2217.0, 104.0]
[909, 452]
p02768
u607075479
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import sys\nimport math\nfrom collections import deque\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\ninput = lambda: sys.stdin.readline().strip()\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\n\ndef combinations_mod(n, r, mod=1000000007):\n """Returns nCr in mod."""\n r = min(r, n - r)\n combs = 1\n for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):\n combs *= (i % mod) * pow(j, mod - 2, mod)\n combs %= mod\n return combs\n\n\ndef main():\n n, a, b = NMI()\n all = pow_mod(2, n, MOD) - 1\n ans = all - combinations_mod(n, a) - combinations_mod(n, b)\n ans %= MOD\n print(ans)\n\n\n\nif __name__ == "__main__":\n main()', 'import sys\nimport math\nfrom collections import deque\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\ninput = lambda: sys.stdin.readline().strip()\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\n\ndef combinations_mod(n, r, mod=1000000007):\n """Returns nCr in mod."""\n r = min(r, n - r)\n combs = 1\n for i, j in zip(range(n - r + 1, n + 1), range(1, r + 1)):\n combs *= (i % mod) * pow(j, mod - 2, mod)\n combs %= mod\n return combs\n\n\ndef main():\n n, a, b = NMI()\n all = pow(2, n, MOD) - 1\n ans = all - combinations_mod(n, a) - combinations_mod(n, b)\n ans %= MOD\n print(ans)\n\n\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s868942799', 's674318562']
[3444.0, 3316.0]
[22.0, 1523.0]
[725, 721]
p02768
u608007704
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b=map(int,input().split())\n\ndef two_n(x):\n #calc2**n-1\n ans=0\n base=2\n for i in range(18):\n if n&1<<i:\n ans+=base\n ans%=10**9+7\n base*=2\n base%=10**9+7\nprint(two_n(1))\nprint(two_n(2))\nprint(two_n(3))', 'n,a,b=map(int,input().split())\n\ndef genCombinationFunction(max_k,mod):\n modinv_table = [-1] * (max_k+1)\n modinv_table[1] = 1\n for i in range(2, max_k+1):\n modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod\n\n def binomial_coefficients(n, k):\n ans = 1\n for i in range(k):\n ans *= n-i\n ans *= modinv_table[i + 1]\n ans %= mod\n return ans\n return binomial_coefficients\n\n \nmax_k = 2 * 10 ** 5\nmod = 10**9 + 7\nf=genCombinationFunction(max_k,mod)\n\n\nans=pow(2,n,mod)-1\nans-=f(n,a)\nans-=f(n,b)\nprint(ans%mod)']
['Wrong Answer', 'Accepted']
['s835609465', 's966321913']
[9176.0, 16948.0]
[31.0, 174.0]
[230, 586]
p02768
u619197965
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b=[int(i) for i in input().split()]\ndef power(a,n,mod):\n res=1\n while n>0:\n if n&1:\n res=res*a%mod\n a=a*a%mod\n n>>=1\n return res\n\nans=power(2,n-1,10**9+7)-1\nnum1=1\nnum2=1\nfor i in range(a):\n num1*=(n-i)\n num2*=(i+1)\nans-=num1//num2\nans%=10**9+7\nnum1=1\nnum2=1\nfor i in range(b):\n num1*=(n-i)\n num2*=(i+1)\nans-=num1//num2\nprint(ans%(10**9+7))', 'def modcmb(n,r,mod=10**9+7):\n res=1\n div=min(r,n-r)\n for i in range(div):\n res=res*(n-i)*pow(div-i,mod-2,mod)%mod\n return res%mod\n\nn,a,b=[int(i) for i in input().split()]\nmod=10**9+7\nans=pow(2,n,mod)-1\nans-=modcmb(n,a)\nans%=mod\nans-=modcmb(n,b)\nans%=mod\nprint(ans)']
['Wrong Answer', 'Accepted']
['s954066475', 's171772541']
[3580.0, 3064.0]
[2104.0, 1526.0]
[397, 283]
p02768
u619850971
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import sys\nreadline = sys.stdin.readline\nread = sys.stdin.read\nn,a,b = [int(i) for i in read().split()]\nMOD = 10**9+7\nans = pow(2,n,MOD)-1\n\ndef choose(n,r):\n res = 1\n fac = 1\n for i in range(r):\n res *= n-i\n res %= MOD\n fac *= i+1\n fac %= MOD\n return res*pow(fac,MOD-2,MOD)%MOD \n\n ans -= choose(n,a)\nans -= choose(n,b)\nprint(ans%MOD)', 'import sys\nreadline = sys.stdin.readline\nread = sys.stdin.read\nn,a,b = [int(i) for i in read().split()]\n\nMOD = 10**9+7\nans = pow(2,n,MOD)-1\n\n\ndef choose(n,r):\n res = 1\n fac = 1\n for i in range(r):\n res *= n-i\n res %= MOD\n fac *= i+1\n fac %= MOD\n return res*pow(fac,MOD-2,MOD)%MOD \n\nans -= choose(n,a)\nans -= choose(n,b)\nprint(ans%MOD)']
['Runtime Error', 'Accepted']
['s458201103', 's754525788']
[3064.0, 3064.0]
[18.0, 157.0]
[381, 439]
p02768
u627325970
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def pow_mod(a, n, m): # (a^n) % m\n res = 1\n while n > 0:\n if n % 2 == 1:\n res = (res * a) % m\n a = (a * a) % m\n n = n // 2\n return res\n\ndef combi_mod(p, q, m):\n numerator, denominator = 1, 1\n for i in range(1, q+1):\n numerator *= (p - i + 1)\n numerator %= m\n denominator *= i\n denominator %= m\n return numerator * pow_mod(denominator, m-2, m) % m\n\nn, a, b = list(map(int, input().split()))\nres = pow_mod(2, n, M) - 1\nres -=combi_mod(n, a, M)\nif res < 0:\n res += M\nres -= combi_mod(n, b, M)\nif res < 0:\n res += M\nprint(res)', 'M = pow(10, 9) + 7\n\ndef pow_mod(a, n, m): # (a^n) % m\n res = 1\n while n > 0:\n if n % 2 == 1:\n res = (res * a) % m\n a = (a * a) % m\n n = n // 2\n return res\n\ndef combi_mod(p, q, m):\n numerator, denominator = 1, 1\n for i in range(1, q+1):\n numerator *= (p - i + 1)\n numerator %= m\n denominator *= i\n denominator %= m\n return numerator * pow_mod(denominator, m-2, m) % m\n\nn, a, b = list(map(int, input().split()))\nres = pow_mod(2, n, M) - 1\nres -=combi_mod(n, a, M)\nif res < 0:\n res += M\nres -= combi_mod(n, b, M)\nif res < 0:\n res += M\nprint(res)']
['Runtime Error', 'Accepted']
['s356865085', 's777709574']
[3064.0, 3064.0]
[17.0, 151.0]
[606, 626]
p02768
u642012866
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\n\np = 10**9+7\n\ndef f(x, n, p):\n print(x, n, p)\n if n == 1:\n return x % p\n if n % 2 == 1:\n return (x * f(x, n-1, p)) % p\n y = f(x, n//2, p)\n return (y**2) % p\n\ndef ff(n, m):\n x = 1\n for i in range(n-m+1, n+1):\n x *= i\n x %= p\n return x\n\nres = f(2, n, p) - 1\nres -= (ff(n, a) * f(ff(a, a), p-2, p)) % p\nres -= (ff(n, b) * f(ff(b, b), p-2, p)) % p\n\nwhile res < 0:\n res += p\n\nprint(res)', 'n, a, b = map(int, input().split())\n\np = 10**9+7\n\ndef f(x, n, p):\n if n == 1:\n return x % p\n if n % 2 == 1:\n return (x * f(x, n-1, p)) % p\n y = f(x, n//2, p)\n return (y**2) % p\n\ndef ff(n, m):\n x = 1\n for i in range(n-m+1, n+1):\n x *= i\n x %= p\n return x\n\nres = f(2, n, p) - 1\nres -= (ff(n, a) * f(ff(a, a), p-2, p)) % p\nres -= (ff(n, b) * f(ff(b, b), p-2, p)) % p\n\nwhile res < 0:\n res += p\n\nprint(res)']
['Wrong Answer', 'Accepted']
['s667742465', 's586541389']
[3064.0, 3064.0]
[138.0, 143.0]
[472, 453]
p02768
u644224332
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import math\n\nMOD = 10 ** 9 + 7\n\n\ndef cmb(n, r):\n total = 1\n for i in range(r):\n total *= (n - i) % MOD\n return total * pow(math.factorial(r), MOD - 2, MOD) % MOD\n\n\ndef calc(n, r):\n ret = 1\n for i in range(r):\n ret = ret * (n - i) % MOD\n return ret * pow(factorial(r), MOD - 2, MOD) % MOD\n\n\nif __name__ == \'__main__\':\n n, a, b = list(map(int, input().split(" ")))\n\n total = pow(2, n, MOD)\n a_total = calc(n, a)\n b_total = calc(n, b)\n print((total - a_total - b_total - 1) % MOD)', 'P = 10 ** 9 + 7\nN = 10 ** 9 \nfact = [1, 1]\nfactinv = [1, 1]\ninv = [0, 1]\n\n\ndef cmb(n, r):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n - r] % P\n\n\n\n# return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\nif __name__ == \'__main__\':\n n, a, b = list(map(int, input().split(" ")))\n for i in range(2, N + 1):\n fact.append((fact[-1] * i) % P)\n inv.append((-inv[P % i] * (P // i)) % P)\n factinv.append((factinv[-1] * inv[-1]) % P)\n\n total = pow(2, n, P)\n # print(total)\n a_total = cmb(n, a)\n # print(a_total)\n b_total = cmb(n, b)\n print(total - a_total - b_total - 1)', 'import math\n\nMOD = 10 ** 9 + 7\n\n\ndef cmb(n, r):\n total = 1\n for i in range(r):\n total = total * (n - i) % MOD\n return total * pow(math.factorial(r), MOD - 2, MOD) % MOD\n\n\ndef calc(n, r):\n ret = 1\n for i in range(r):\n ret = ret * (n - i) % MOD\n return ret * pow(math.factorial(r), MOD - 2, MOD) % MOD\n\n\nif __name__ == \'__main__\':\n n, a, b = list(map(int, input().split(" ")))\n\n total = pow(2, n, MOD)\n a_total = cmb(n, a)\n b_total = cmb(n, b)\n print((total - a_total - b_total - 1) % MOD)']
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s479613562', 's607557160', 's893455882']
[3064.0, 220988.0, 5460.0]
[51.0, 2118.0, 1502.0]
[524, 759, 534]
p02768
u646818123
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from math import factorial\n\ndef com(n, r):\n return factorial(n) // facotrial(n - r) // factorial(r)\n\nn, a, b = [int(s) for s in input().split()]\n\nprint((2**n - com(n, a) - com(n, b) - 1) % (10**9 + 7))', 'import functools\n\ndef get_mul_inverse(x: int, p: int) -> int:\n return iterative_square(x, p - 2, p)\n\ndef _iterative_square(x: int, n: int, p: int) -> int:\n if n <= 1:\n return x\n div, mod = divmod(n, 2)\n return (((iterative_square(x, div, p) ** 2) % p) * x ** mod) % p\n\ndef iterative_square(x: int, n: int, p: int) -> int:\n if n <= 0:\n return None\n\n return _iterative_square(x, n, p)\n\ndef factorial(a, b, p):\n x = 1\n\n x = functools.reduce(lambda x, y: (x * y) % p, range(a, b + 1), 1)\n return x\n\ndef com(n, r, p):\n fact_div_r = get_mul_inverse(factorial(1, r, p), p)\n\n _result = factorial(n - r + 1, n, p)\n result = (_result * fact_div_r) % p\n \n return result\n\n\nn, a, b = [int(i) for i in input().split()]\np = 10**9 + 7\n\n\npow_2_n_1 = iterative_square(2, n, p) - 1\n\n_result = pow_2_n_1 - com(n, a, p)\n\n_result = _result - com(n, b, p)\n\nresult = _result % p\nprint(result)']
['Runtime Error', 'Accepted']
['s967277789', 's376930125']
[199356.0, 3572.0]
[2107.0, 157.0]
[202, 908]
p02768
u652656291
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int,input().split())\nmod = 10**9+7\nALL = pow(2,n,m)-1\nx = y = 1\nfor i in range(b):\n x = x * (i+1)%m\n y = y * (n-i)%m\n if i + 1 == a:\n a = b\n ALL -= y * pow(x,m-2,m)\nprint(ALL%m)\n', 'import math\n\nn,a,b = map(int,input().split())\nmod = 10**9+7\ntotal = pow(2,n,mod) - 1\n\nnPa = math.factorial(n) // math.factorial(n-a) \nnPa %= mod\nnPb = math.factorial(n) // math.factorial(n-b) \nnPb %= mod\na!_1 = 1\nfor i in range(1,a+1):\n a!_1 = pow(i,mod-2,mod)\n a!_1 %= mod\nb!_1 = 1\nfor i in range(1,b+1):\n b!_1 = pow(i,mod-2,mod)\n b!_1 %= mod\nnCa = nPa * a!_1\nnCb = nPb * b!_1\nprint((total-nCa-nCb)%mod)', 'mod = 10**9+7\nn,a,b = map(int,input().split())\nans = pow(2,n,mod)-1\n\ncomb1 = 1 \nfor i in range(n-a+1,n+1):\n comb1 *= i\n comb1 %= mod\nfor i in range(1,a+1):\n comb1 *= pow(i,mod-2,mod)\n comb1 %= mod\n\ncomb2=1\nfor i in range(n-b+1,n+1):\n comb2 *= i\n comb2 %= mod\nfor i in range(1,b+1):\n comb2 *= pow(i,mod-2,mod)\n comb2 %= mod\n \nans -= (comb1+comb2)\nans %= mod\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s697574731', 's985146896', 's790456919']
[3060.0, 3064.0, 3064.0]
[18.0, 17.0, 1603.0]
[213, 408, 377]
p02768
u657786757
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import sys\nimport math\nfrom collections import deque\nfrom collections import defaultdict\n\ndef main():\n n,a,b = list(map(int,sys.stdin.readline().split()))\n mod = 10**9 + 7\n ans = 1\n C = 1\n for i in range(n-1):\n C = C * (n - i) // (i + 1)\n #print("C=",C)\n if not i == a or i == b:\n ans += C % mod\n #print(ans)\n print(ans)\n \n return 0\n\nif __name__ == "__main__":\n main()', 'import sys\nimport math\nfrom collections import deque\nfrom collections import defaultdict\n\ndef main():\n n,a,b = list(map(int,sys.stdin.readline().split()))\n mod = 10**9 + 7\n ans = 1\n C = 1\n for i in range(n-1):\n C = C * (n - i) // (i + 1)\n #print("C=",C)\n if not i == a or i == b:\n ans += C\n ans = ans % mod\n #print(ans)\n print(ans)\n \n return 0\n\nif __name__ == "__main__":\n main()', 'import sys\nimport math\nfrom collections import deque\nfrom collections import defaultdict\n\ndef comb(n, r, mod):\n X, Y = 1, 1\n for i in range(r):\n X = X * (n - i) % mod\n Y = Y * (r - i) % mod\n return X * pow(Y, mod-2, mod)\n\ndef main():\n n,a,b = list(map(int,sys.stdin.readline().split()))\n mod = 10**9 + 7\n ans = pow(2, n, mod) - 1\n ans = (ans - comb(n, a, mod) - comb(n, b, mod)) % mod\n print(ans)\n return 0\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s160081720', 's231872334', 's980718835']
[3436.0, 3436.0, 3316.0]
[2104.0, 2104.0, 136.0]
[438, 460, 486]
p02768
u667084803
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from functools import reduce\n \ndef perm(n, k, p):\n ret = 1\n for i in range(n, n-k-1, -1):\n ret = (ret * i)%p\n return ret\n\ndef comb(n, k, p):\n \n a = perm(n, k, p)\n b = perm(k, k, p)\n return (a*pow(b, p-2, p))%p\n \nn, a, b = map(int, input().split())\n\nMOD = 10**9 + 7\n\n\nprint((pow(2,n,MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD))%MOD)', 'from functools import reduce\n \ndef perm(n, k, p):\n ret = 1\n for i in range(n, n-k-1, -1):\n ret = (ret * i) % p\n return ret\n\ndef comb(n, k, p):\n \n a = perm(n, k, p)\n b = perm(n, n-k, p)\n return (a*pow(b, p-2, p))%p\n \nn, a, b = map(int, input().split())\n\nMOD = 10**9 + 7\n\n\nprint((pow(2,n,MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD))%MOD)', '\nfrom functools import reduce\n \ndef comb(n, k, p):\n \n a = reduce(lambda x,y: x*y%MOD, range(n,n-k,-1))\n b = reduce(lambda x,y: x*y%MOD, range(1,k+1))\n return (a*b)%p\n \nn, a, b = map(int, input().split())\n\nMOD = 10**9 + 7\n\n\nprint((pow(2,n,MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD))%MOD)', 'def power_func(a, b, p):\n \n if b==0: return 1\n if b%2==0:\n d=power_func(a,b//2,p)\n return d*d %p\n if b%2==1:\n return (a*power_func(a,b-1,p ))%p\n \ndef comb(n, k, p):\n \n from math import factorial\n if n<0 or k<0 or n<k: return 0\n if n==0 or k==0: return 1\n a = factorial(n) % p\n b = power_func(factorial(k) % p, p-2, p)\n c = power_func(factorial(n-k) % p, p-2, p)\n return (a*b*c)%p\n \nn, a, b = map(int, input().split())\n\nMOD = 10**9 + 7\n\n\nprint((pow(2,n,MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD))', 'from functools import reduce\n \ndef perm(n, k, p):\n ret = 1\n for i in range(n, n-k, -1):\n ret = (ret * i)%p\n return ret\n\ndef comb(n, k, p):\n \n a = perm(n, k, p)\n b = perm(n, n-k, p)\n return (a*pow(b, p-2, p))%p\n \nn, a, b = map(int, input().split())\n\nMOD = 10**9 + 7\n\n\nprint((pow(2,n,MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD))%MOD)', 'from functools import reduce\n \ndef perm(n, k, p):\n ret = 1\n for i in range(n, n-k, -1):\n ret = (ret * i)%p\n return ret\n\ndef comb(n, k, p):\n \n a = perm(n, k, p)\n b = perm(k, k, p)\n return (a*pow(b, p-2, p))%p\n \nn, a, b = map(int, input().split())\n\nMOD = 10**9 + 7\n\n\nprint((pow(2,n,MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD))%MOD)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s359902299', 's430151829', 's594900984', 's716379007', 's877855864', 's934572765']
[3572.0, 3700.0, 3700.0, 3064.0, 3572.0, 3684.0]
[114.0, 2104.0, 158.0, 17.0, 2104.0, 114.0]
[396, 400, 346, 600, 396, 394]
p02768
u677121387
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int,input().split())\nmod = 10**9+7\na = min(a,n-a)\nb = min(b,n-b)\nm = max(a,b)\nX = [0]*(m+1)\nY = [0]*(m+1)\nX[0] = 1\nX[1] = n\nY[0] = Y[1] = 1\n\nfor i in range(1,m):\n X[i] = X[i-1]*(n-i)%mod\n Y[i] = Y[i-1]*(i+1)%mod\n\na -= 1\nb -= 1\nans = (((pow(2,n,mod)-1)%mod-X[a]*pow(Y[a],mod-2,mod)%mod)%mod-X[b]*pow(Y[b],mod-2,mod)%mod)%mod\nprint(ans)', 'n,a,b = map(int,input().split())\nmod = 10**9+7\ndef combmod(n,k,mod):\n x = y = 1\n for i in range(min(k,n-k)):\n x = x*(n-i)%mod\n y = y*(i+1)%mod\n return x * pow(y, mod-2, mod) % mod\nans = (((pow(2, n, mod) - 1)%mod - combmod(n, a, mod))%mod - combmod(n, b, mod))%mod\nprint(ans)']
['Wrong Answer', 'Accepted']
['s643023903', 's846379786']
[18804.0, 3064.0]
[166.0, 144.0]
[352, 298]
p02768
u678167152
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['inp = [int(i) for i in input().split()]\nn = inp[0]\na = inp[1]\nb = inp[2]\n\n# C = {}\n\n# print(n,r)\n# if r==0 or r ==n:\n# return 1\n# if r==1:\n# return n\n# if (n,r) in C:\n# return C[(n,r)]\n# C[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n# return C[(n,r)]\n\n\n# if n - r < r: r = n - r\n# if r == 0: return 1\n# if r == 1: return n\n#\n\n# denominator = [k + 1 for k in range(r)]\n#\n# for p in range(2,r+1):\n\n\n# offset = (n - r) % p\n# for k in range(p-1,r,p):\n# numerator[k - offset] /= pivot\n\n#\n# result = 1\n# for k in range(r):\n# if numerator[k] > 1:\n# result *= int(numerator[k])\n#\n# return result\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nA = cmb(n,a,mod)\nB = cmb(n,b,mod)\nans = 2**n-1-A-B\nprint(ans%(10**9+7))', 'n,a,b = [int(i) for i in input().split()]\nmod = 10**9+7\n\ndef mpow(a,n):\n if n == 1:\n return a\n x = mpow(a,n//2)\n ans = x*x%mod\n if n%2==1:\n ans *= a\n return ans\n\ndef comb(n,a,b):\n if a < b:\n s, l = a, b\n else:\n s, l = b, a\n rs = 1\n for i in range(s):\n rs = rs*(n-i)%mod\n rl = rs\n for i in range(s,l):\n rl = rl*(n-i)%mod\n for i in range(1,s+1):\n rs = rs*mpow(i,mod-2)%mod\n rl = rl\n for i in range(s+1,l+1):\n rl = rl*mpow(i,mod-2)%mod\n if a < b:\n nCa, nCb = rs, rl\n else:\n nCa, nCb = rl, rs\n return nCa, nCb\nnCa,nCb = comb(n,a,b)\nprint((mpow(2,n)-1-nCa-nCb)%mod)\nprint(nCa,nCb)', 'inp = [int(i) for i in input().split()]\nn = inp[0]\na = inp[1]\nb = inp[2]\n\n# C = {}\n\n# print(n,r)\n# if r==0 or r ==n:\n# return 1\n# if r==1:\n# return n\n# if (n,r) in C:\n# return C[(n,r)]\n# C[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n# return C[(n,r)]\n\n\n# if n - r < r: r = n - r\n# if r == 0: return 1\n# if r == 1: return n\n#\n\n# denominator = [k + 1 for k in range(r)]\n#\n# for p in range(2,r+1):\n\n\n# offset = (n - r) % p\n# for k in range(p-1,r,p):\n# numerator[k - offset] /= pivot\n\n#\n# result = 1\n# for k in range(r):\n# if numerator[k] > 1:\n# result *= int(numerator[k])\n#\n# return result\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 2*10**5\nM = 10**9\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, n + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\n\n# mod = 10**9+7\n# MAX_N = 10**9\n\n# fact = [1]\n# fact_inv = [0]*(MAX_N+4)\n\n# fact.append(fact[-1]*(i+1)%mod)\n#\n\n\n# fact_inv[i] = fact_inv[i+1]*(i+1)%mod\n#\n#\n\n# return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod\n\nA = mod_cmb_k(n,a,mod)\nB = mod_cmb_k(n,b,mod)\nans = 2**n-1-A-B\nprint(ans%(10**9+7))', 'inp = [int(i) for i in input().split()]\nn = inp[0]\na = inp[1]\nb = inp[2]\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**9\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nA = cmb(n,a,mod)\nB = cmb(n,b,mod)\nans = 2**n-1-A-B\nprint(ans%(10**9+7))', 'inp = [int(i) for i in input().split()]\nn = inp[0]\na = inp[1]\nb = inp[2]\n\n# C = {}\n\n# print(n,r)\n# if r==0 or r ==n:\n# return 1\n# if r==1:\n# return n\n# if (n,r) in C:\n# return C[(n,r)]\n# C[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n# return C[(n,r)]\n\n\n# if n - r < r: r = n - r\n# if r == 0: return 1\n# if r == 1: return n\n#\n\n# denominator = [k + 1 for k in range(r)]\n#\n# for p in range(2,r+1):\n\n\n# offset = (n - r) % p\n# for k in range(p-1,r,p):\n# numerator[k - offset] /= pivot\n\n#\n# result = 1\n# for k in range(r):\n# if numerator[k] > 1:\n# result *= int(numerator[k])\n#\n# return result\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 2*10**5\nM = 10**9\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, n + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\n\n# mod = 10**9+7\n# MAX_N = 10**9\n\n# fact = [1]\n# fact_inv = [0]*(MAX_N+4)\n\n# fact.append(fact[-1]*(i+1)%mod)\n#\n\n\n# fact_inv[i] = fact_inv[i+1]*(i+1)%mod\n#\n#\n\n# return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod\n\nA = cmb(n,a,mod)\nB = cmb(n,b,mod)\nans = 2**n-1-A-B\nprint(ans%(10**9+7))', 'inp = [int(i) for i in input().split()]\nn = inp[0]\na = inp[1]\nb = inp[2]\n\nC = {}\ndef cmb(n,r):\n print(n,r)\n if r==0 or r ==n:\n return 1\n if r==1:\n return n\n if (n,r) in C:\n return C[(n,r)]\n C[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n return C[(n,r)]\n \nA = cmb(n,a)\nB = cmb(n,b)\nans = 2**n-1-A-B\nprint(ans%(10**9+7))', 'def comb_mod(n,r):\n mod = 10**9+7\n ans = 1\n for i in range(r):\n ans *= n-i\n ans %= mod\n for i in range(1,r+1):\n ans *= pow(i,-1,mod)\n ans %= mod\n return ans\n\ndef solve():\n n, a, b = map(int, input().split())\n mod = 10**9+7\n ans = pow(2,n,mod)-comb_mod(n,a)-comb_mod(n,b)-1\n ans %= mod\n return ans\nprint(solve())']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s506097533', 's581715419', 's674681869', 's737852698', 's801295660', 's909900858', 's316536800']
[4328.0, 3064.0, 220420.0, 227732.0, 221764.0, 4216.0, 9188.0]
[29.0, 2104.0, 2119.0, 2119.0, 2123.0, 77.0, 606.0]
[1407, 622, 1808, 603, 1796, 325, 369]
p02768
u680851063
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int,input().split())\nprint(n,a,b)\n\nimport math\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nl = [int(i) for i in range(1,n+1)]\nprint(l)\n\nx = 0\nfor j in range(n):\n x += combinations_count(n, l[j])\n\ny = combinations_count(n, a) + combinations_count(n, b)\n\nprint((x-y)/(10**9+7))\n', 'n, a, b = map(int,input().split())\nprint(n,a,b)\n\nimport math\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nl = [int(i) for i in range(1,n+1)]\n#print(l)\n\nx = 0\nfor j in range(n):\n x += combinations_count(n, l[j])\n\ny = combinations_count(n, a) + combinations_count(n, b)\n\nprint((x-y)/(10**9+7))', 'n,a,b = map(int,input().split())\n\nmod = 10**9+7\ntotal = pow(2,n,mod) - 1 \n\n\n\ndef nCr(n, r, mod):\n numerator=1 \n for i in range(n-r+1, n+1):\n numerator = (numerator*i) % mod\n\n denominator=1 \n for j in range(1,r+1):\n denominator = (denominator*j) % mod\n \n \n return (numerator * pow(denominator,mod-2,mod)) % mod\n \nans = (total - nCr(n,a,mod) - nCr(n,b,mod)) % mod\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s370264357', 's726251128', 's271767950']
[728984.0, 730648.0, 9076.0]
[2148.0, 2149.0, 101.0]
[357, 357, 916]
p02768
u686713618
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\ndef power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\nN, a, b = map(int, input().split())\nmod = 10**9+7\nALL = power_func(2,N,mod)-1\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\nA = cmb(N, a, mod)\nB = cmb(N, b, mod)\nAns = (ALL - A - B)\nprint(A,B,ALL,Ans)', 'def cmb(n, r):\n if n - r < r:\n r = n - r\n if r == 0: \n return 1\n if r == 1: \n return n\n numerator = [] \n mod = 10**9+7\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n result %= mod\n\n return result\n\ndef power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\nn, a, b = map(int, input().split())\nmod = 10**9+7\nALL = power_func(2,n,mod)-1\nA = cmb(n,a)\nB = cmb(n, b)\nprint(ALL,A,B)', 'def cmb(n, r):\n if n - r < r:\n r = n - r\n if r == 0: \n return 1\n if r == 1: \n return n\n numerator = [] \n mod = 10**9+7\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n result %= mod\n\n return result\ndef power_func(a,n,p):\n bi=str(format(n,"b"))\n res=1\n for i in range(len(bi)):\n res=(res*res) %p\n if bi[i]=="1":\n res=(res*a) %p\n return res\nn, a, b = map(int, input().split())\nmod = 10**9+7\nALL = power_func(2,n,mod)-1\nA = cmb(n,a)\nB = cmb(n, b)\nans = ALL-A-B\nwhile ans < 0:\n ans = mod + ans\nprint(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s005590209', 's442311752', 's996521054']
[225876.0, 27700.0, 27700.0]
[2118.0, 694.0, 650.0]
[645, 913, 956]
p02768
u697386253
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int, input().split())\ns = 0\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nfor i in range(n):\n s += cmb(n,i,mod)\n\ns -= cmb(n,a,mod)\ns -= cmb(n,b,mod)\nprint(s)', 'def comb(n, r, p):\n numer = 1\n denom = 1\n \n for i in range(n-r+1, n+1):\n numer = numer * i % p\n for i in range(1, r+1):\n denom = denom * i % p\n return numer * pow(denom, p-2, p) % p\n \np = pow(10, 9) + 7\nn, a, b = map(int, input().split())\nprint(((pow(2, n, p) - comb(n, a, p) - comb(n, b, p) - 1)) % p)\n ']
['Runtime Error', 'Accepted']
['s465758040', 's438106710']
[4340.0, 3060.0]
[29.0, 109.0]
[586, 333]
p02768
u697559326
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
["def pow(x, n, mod):\n ans = 1\n while(n > 0):\n if(bin(n & 1) == bin(1)):\n ans = ans*x % mod\n x = x*x % mod\n n = n >> 1\n return ans\n\ndef kaijou_k(n, k, mod):\n a = 1\n for i in range(k, n+1):\n a *= i\n a %= mod\n return a %mod\n\ndef main():\n n, a, b = map(int, input().split())\n mod = 10**9 +7\n allsum = pow(2, n, mod)-1\n abunbo = kaijou_k(n, n-a+1, mod)\n abunsi = kaijou_k(a, 1, mod)\n asum = abunbo * pow(abunsi, mod-2, mod) % mod\n bbunbo = kaijou_k(n, n-b+1, mod)\n bbunsi = kaijou_k(b, 1, mod)\n bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod\n ans = (allsum - asum - bsum) % mod\n print(ans, asum, bsum)\n\nif __name__ == '__main__':\n main()", "def pow(x, n, mod):\n ans = 1\n while(n > 0):\n if(bin(n & 1) == bin(1)):\n ans = ans*x % mod\n x = x*x % mod\n n = n >> 1\n return ans\n\ndef kaijou_k(n, k, mod):\n a = 1\n for i in range(k, n+1):\n a *= i\n a %= mod\n return a\n\ndef kaijou2(n, k, mod):\n nu, de = 1, 1\n for i in range(1, k+1):\n nu *= (k-i+1)\n nu %= mod\n de *= i\n de %= mod\n return nu * pow(de, mod-2, mod) % mod\n\n\ndef main():\n n, a, b = map(int, input().split())\n mod = 10**9 +7\n allsum = pow(2, n, mod)-1\n abunbo = kaijou_k(n, n-a+1, mod)\n abunsi = kaijou_k(a, 1, mod)\n asum = abunbo * pow(abunsi, mod-2, mod) % mod\n bbunbo = kaijou_k(n, n-b+1, mod)\n bbunsi = kaijou_k(b, 1, mod)\n bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod\n \n \n ans = allsum - asum - bsum\n print(ans)\n print(allsum)\n \nif __name__ == '__main__':\n main()", "def pow(x, n, mod):\n ans = 1\n while(n > 0):\n if(bin(n & 1) == bin(1)):\n ans = ans*x % mod\n x = x*x % mod\n n = n >> 1\n return ans\n\ndef kaijou_k(n, k, mod):\n a = 1\n for i in range(k, n+1):\n a *= i % mod\n return a\n\ndef main():\n n, a, b = map(int, input().split())\n mod = 10**9 +7\n allsum = pow(2, n, mod)-1\n abunbo = kaijou_k(n, n-a+1, mod)\n abunsi = kaijou_k(a, 1, mod)\n asum = abunbo * pow(abunsi, mod-2, mod) % mod\n bbunbo = kaijou_k(n, n-b+1, mod)\n bbunsi = kaijou_k(b, 1, mod)\n bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod\n ans = allsum - asum - bsum\n #print(allsum, asum, bsum, ans)\n \nif __name__ == '__main__':\n main()", "def pow(x, n, mod):\n ans = 1\n while(n > 0):\n if(bin(n & 1) == bin(1)):\n ans = ans*x % mod\n x = x*x % mod\n n = n >> 1\n return ans\n\ndef kaijou_k(n, k, mod):\n a = 1\n for i in range(k, n+1):\n a *= i\n a %= mod\n return a %mod\n\ndef main():\n n, a, b = map(int, input().split())\n mod = 10**9 +7\n allsum = pow(2, n, mod)-1\n abunbo = kaijou_k(n, n-a+1, mod)\n abunsi = kaijou_k(a, 1, mod)\n asum = abunbo * pow(abunsi, mod-2, mod) % mod\n bbunbo = kaijou_k(n, n-b+1, mod)\n bbunsi = kaijou_k(b, 1, mod)\n bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod\n ans = (allsum - asum - bsum) % mod\n print(ans)\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s342604404', 's695265574', 's940466101', 's728806908']
[3188.0, 3064.0, 3784.0, 3192.0]
[148.0, 149.0, 2108.0, 145.0]
[706, 955, 695, 695]
p02768
u698919163
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = list(map(int,input().split()))\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**9\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nnCa = cmb(n,a,mod)\nnCb = cmb(n,b,mod)\nans = (int(pow(2,n)) - nCa - nCb - 1)%10**9+7\n\nprint(ans)', 'n,a,b = list(map(int,input().split()))\n\nMOD = 10**9+7\n\ndef comb(n,r,MOD):\n x = n+1\n y = min(r,n-r)\n \n numer = 1\n denom = 1\n \n for i in range(1,r+1):\n numer = numer*(x-i)%MOD\n denom = denom*(i)%MOD\n \n return numer * pow(denom,MOD-2,MOD) % MOD\n\nnCa = comb(n,a,MOD)\nnCb = comb(n,b,MOD)\n\nans = pow(2,n,MOD)-1 - nCa - nCb\n\nif ans < 0:\n print((ans+MOD)%MOD)\nelse:\n print(ans%MOD)']
['Time Limit Exceeded', 'Accepted']
['s039934148', 's014018072']
[227472.0, 3064.0]
[2119.0, 131.0]
[593, 420]
p02768
u699008198
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map( int, input().split() )\n\nmod = 10 ** 9 + 7\n\ndef comb( n, r, mod ):\n c = 1\n m = 1\n r = min( n - r, r )\n for i in range( r ):\n c = c * ( n - i ) % mod\n m = m * ( i + 1 ) % mod\n return c * pow( m, mod - 2, mod ) % mod\n\nN = pow( 2, n, mod )\nA = comb( n, a )\nB = comb( n, b )\nprint(( N - A - B ) % mod )', 'n, a, b = map( int, input().split())\nmod = 10 ** 9 + 7\n\ndef nCr( n, r ):\n f = 1\n inv = 1\n for i in range( 1, min( n - r, r ) + 1 ):\n f = f * ( n - i + 1 ) % mod\n inv = inv * i % mod\n return f * pow( inv, mod - 2, mod ) % mod\n\nN = pow( 2, n, mod )\nA = nCr( n, a )\nB = nCr( n, b )\nprint( ( N - A - B ) % mod )\n', 'N, a, b = map( int, input().split())\nmod = 10 ** 9 + 7\n\ndef nCr( n, r ):\n f = 1\n inv = 1\n for i in range( 1, min( n - r, r ) + 1 ):\n f = f * ( n - i + 1 ) % mod\n inv = inv * i % mod\n return f * pow( inv, mod - 2, mod ) % mod\n\nA = nCr( N, a )\nB = nCr( N, b )\nN = pow( 2, N, mod )\nprint( ( N - A - B ) % mod )\n', 'n, a, b = map( int, input().split() )\nmod = 10 ** 9 + 7\n\nN = pow( 2, n, mod ) - 1\n\ndef comb( n, r ):\n c = 1\n m = 1\n r = min( n - r, r )\n for i in range( r ):\n c = c * ( n - i ) % mod\n m = m * ( i + 1 ) % mod\n return c * pow( m, mod - 2, mod ) % mod\n\nA = comb( n, a )\nB = comb( n, b )\nprint( ( N - A - B ) % mod )']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s669345630', 's765628200', 's940443153', 's053130270']
[3064.0, 3064.0, 3188.0, 3064.0]
[19.0, 147.0, 152.0, 152.0]
[323, 318, 318, 324]
p02768
u703214333
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,m=map(int,input().split())\nmod=10**9+7\nif abs(n-m)>1:\n print(0)\n exit()\na,b=[1,1]\nfor i in range(1,min(n,m)+1):\n a=(a*i)%mod\nif n!=m:\n b*=max(n,m)*a\n print((a*b)%mod)\nelse:\n b=a\n print((2*a*b)%mod)', 'mod=10**9+7\nimport math\n\ndef co(n,r,mod):\n x=1\n y=1\n for i in range(1,r+1):\n x=(x*(n-i+1))%mod\n y=(y*i)%mod\n return (x*pow(y,mod-2,mod))%mod\n \nn,a,b=map(int,input().split())\nans=pow(2,n,mod)-1-co(n,a,mod)-co(n,b,mod)\nprint(max(ans%mod,0))']
['Runtime Error', 'Accepted']
['s995787468', 's528628403']
[3064.0, 3064.0]
[17.0, 140.0]
[220, 298]
p02768
u704284486
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def mpow(a,n,mod):\n if n == 0:\n return 1\n elif n == 1:\n return a\n elif n%2==0:\n return (pow(a,n/2,mod))**2%mod\n else:\n return a*pow(a,n-1,mod)%mod\ndef mfac(l,r,mod):\n ans = l\n for i in reversed(range(r,l)):\n ans *= i\n ans %= mod\n return ans\ndef mcomb(n,k,mod):\n A = mfac(n,n-k+1)\n B = mfac(k,1)\n B = mpow(B,mod-2,mod)\n return A*B%mod\n\ndef main():\n mod = 10**9+7\n n,a,b = map(int,input().split(" "))\n ans = mpow(2,n,mod)-1+mcomb(n,a,mod)-mcomv(n,b,mod)\n ans %= mod\n print(ans)\n\nif __name__ == "__main__":\n main()\n ', 'def mpow(a,n,mod):\n if n == 0:\n return 1\n elif n == 1:\n return a\n elif n%2==0:\n return (pow(a,n//2,mod))**2%mod\n else:\n return a*pow(a,n-1,mod)%mod\ndef mfac(l,r,mod):\n ans = l\n for i in reversed(range(r,l)):\n ans *= i\n ans %= mod\n return ans\ndef mcomb(n,k,mod):\n A = mfac(n,n-k+1,mod)\n B = mfac(k,1,mod)\n B = mpow(B,mod-2,mod)\n return A*B%mod\n\ndef main():\n mod = 10**9+7\n n,a,b = map(int,input().split(" "))\n ans = mpow(2,n,mod)-1-mcomb(n,a,mod)-mcomb(n,b,mod)\n ans %= mod\n print(ans)\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s924597888', 's300935717']
[3188.0, 3064.0]
[19.0, 145.0]
[549, 555]
p02768
u706330549
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from functools import reduce\nimport sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\nn, a, b = map(int, read().split())\nMOD = 10 ** 9 + 7\n\n\ndef combo_mod(n, a):\n t = reduce(lambda x, y: x * y % MOD, range(n, n - a, -1))\n b = reduce(lambda x, y: x * y % MOD, range(1, a + 1))\n return t // b\n\n\nans = pow(2, n, MOD) - combo_mod(a) - combo_mod(b) - 1\nans %= MOD\n\nprint(ans)\n', 'from functools import reduce\nimport sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\nn, a, b = map(int, read().split())\nMOD = 10 ** 9 + 7\n\n\ndef comb_mod(n, a):\n num = reduce(lambda x, y: x * y % MOD, range(n, n - a, -1))\n den = reduce(lambda x, y: x * y % MOD, range(1, a + 1))\n return num * pow(den, MOD - 2, MOD) % MOD\n\n\nans = pow(2, n, MOD) - comb_mod(n, a) - comb_mod(n, b) - 1\nans %= MOD\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s174525729', 's875705057']
[3828.0, 3700.0]
[28.0, 159.0]
[402, 437]
p02768
u707808519
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['# coding: utf-8\nMOD = 10**9+7\n\n\ndef modpow(a, n):\n res = 1\n while n > 0:\n if n & 1:\n res = res * a % MOD\n a = a * a % MOD\n n >>= 1\n return res\n\n# nCr mod.p (n <= 10**6)\nMAX = 1000010\nfac = [0] * MAX \nfinv = [0] * MAX\ninv = [0] * MAX\ndef COMinit():\n fac[0] = fac[1] = 1\n finv[0] = finv[1] = 1\n inv[1] = 1\n for i in range(2, MAX):\n fac[i] = fac[i-1] * i % MOD\n inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD\n finv[i] = finv[i-1] * inv[i] % MOD\n\ndef COM(n, k):\n res = 1\n for i in range(k):\n res = res * (n-i) % MOD\n return res * finv[k] % MOD\n\nCOMinit()\nn, a, b = map(int, input().split())\ntot = modpow(2, 10**9) - 1\nans = (tot - COM(n,a) - COM(n,b)) % MOD\nprint(ans)', '# coding: utf-8\nMOD = 10**9+7\n\n\ndef modpow(a, n):\n res = 1\n while n > 0:\n if n & 1:\n res = res * a % MOD\n a = a * a % MOD\n n >>= 1\n return res\n\n# nCr mod.p (n <= 10**6)\nMAX = 1000010\nfac = [0] * MAX \nfinv = [0] * MAX\ninv = [0] * MAX\ndef COMinit():\n fac[0] = fac[1] = 1\n finv[0] = finv[1] = 1\n inv[1] = 1\n for i in range(2, MAX):\n fac[i] = fac[i-1] * i % MOD\n inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD\n finv[i] = finv[i-1] * inv[i] % MOD\n\ndef COM(n, k):\n res = 1\n for i in range(k):\n res = res * (n-i) % MOD\n return res * finv[k] % MOD\n\nCOMinit()\nn, a, b = map(int, input().split())\ntot = modpow(2,n) - 1\nans = (tot - COM(n,a) - COM(n,b)) % MOD\nprint(ans)']
['Wrong Answer', 'Accepted']
['s349253992', 's407574664']
[121844.0, 121716.0]
[1204.0, 1284.0]
[829, 824]
p02768
u712284046
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import math\nn, a, b = map(int, input().split())\nx = 1\nmy_list = [0] * n\n\nfor i in range(n):\n x = x * (n - i) // (i + 1)\n my_list[i] = x\n\nmy_list[a-1] = 0\nmy_list[b-1] = 0\n\nprint(my_list)\nprint(sum(my_list) %(10**9 + 7) )\n', 'n, a, b = map(int, input().split())\np = 1000000007\n\ndef remainder_of_combination(n, r, p):\n X = 1\n Y = 1\n \n for i in range(n - r +1, n + 1):\n X = X * i % p\n for i in range(1, r + 1):\n Y = Y * i % p\n \n return X * pow(Y, p-2, p)\n\nans = -1 + pow(2, n, p) - remainder_of_combination(n, a, p) - remainder_of_combination(n, b, p)\n\nprint(ans % p)']
['Runtime Error', 'Accepted']
['s187479888', 's906086097']
[1505780.0, 3064.0]
[2137.0, 108.0]
[227, 378]
p02768
u729008627
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\np = 10**9 + 7\ndef ModComb(n, r, p):\n N = n%p\n R = r%p\n if N<R:\n return 0\n if N < 2*R:\n R = N-R\n if R == 0:\n return 1\n else:\n return (n*pow(r, p-2, p))%p*ModComb(n-1, r-1, p)\n\nans = 1\nfor i in range(N):\n ans *= 2\n ans = ans%p\nans = ans - 1 - ModComb(n, a, p) - ModComb(n, b, p)\nans = ans%p\nprint(ans)', 'def cmb(n, r, p):\n A = 1\n B = 1\n r = min(r, n - r)\n for i in range(r):\n A = A * (n-i) % p\n B = B * (i+1) % p\n return A * pow(B, p-2, p) % p\n\nn, a, b = map(int, input().split())\np = 10**9 + 7\nA = pow(2, n, p) - 1 - cmb(n, a, p) - cmb(n, b, p)\nA = A%p\nprint(A)']
['Runtime Error', 'Accepted']
['s584561346', 's224947445']
[3064.0, 3064.0]
[18.0, 142.0]
[383, 287]
p02768
u730107446
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def modpow(a,n):\n if n==0:\n return 1\n elif n==1:\n return a%mod\n elif n%2==0:\n return (modpow(a,n/2)**2)%mod\n else:\n return (a*modpow(a,n-1))%mod\n\ndef modfact(l,r):\n fact=1\n for i in range(l-r+1):\n fact=fact*(r+i)%mod\n return fact\n\ndef comb(n,x):\n S=modfact(n,n-x+1)\n fact=modfact(x,1)\n T=modpow(fact,mod-2)\n print(S,fact,T,S*T%mod)\n return S*T%mod\n\nn,a,b=map(int,input().split())\nfact=modpow(2,n)\nans=fact-1-comb(n,a)-comb(n,b)\nwhile ans<0:\n ans+=mod\nprint(ans)', 'mod=10**9+7\n\ndef modpow(a,n):\n if n==0:\n return 1\n elif n==1:\n return a%mod\n elif n%2==0:\n return (modpow(a,n/2)**2)%mod\n else:\n return (a*modpow(a,n-1))%mod\n\ndef modfact(l,r):\n fact=1\n for i in range(l-r+1):\n fact=fact*(r+i)%mod\n return fact\n\ndef comb(n,x):\n S=modfact(n,n-x+1)\n fact=modfact(x,1)\n T=modpow(fact,mod-2)\n return S*T%mod\n\nn,a,b=map(int,input().split())\nfact=modpow(2,n)\nans=fact-1-comb(n,a)-comb(n,b)\nwhile ans<0:\n ans+=mod\nprint(ans)']
['Runtime Error', 'Accepted']
['s639760829', 's194978019']
[3112.0, 3188.0]
[20.0, 152.0]
[535, 520]
p02768
u731368968
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['MOD = 10 ** 9 + 7\n\n\nclass ModInt:\n def __init__(self, x):\n self.x = x % MOD\n\n def __str__(self):\n return str(self.x)\n\n __repr__ = __str__\n\n def __add__(self, other):\n return (\n ModInt(self.x + other.x) if isinstance(other, ModInt) else\n ModInt(self.x + other)\n )\n\n def __sub__(self, other):\n return (\n ModInt(self.x - other.x) if isinstance(other, ModInt) else\n ModInt(self.x - other)\n )\n\n def __mul__(self, other):\n return (\n ModInt(self.x * other.x) if isinstance(other, ModInt) else\n ModInt(self.x * other)\n )\n\n def __truediv__(self, other):\n return (\n ModInt(\n self.x * pow(other.x, MOD - 2, MOD)\n ) if isinstance(other, ModInt) else\n ModInt(self.x * pow(other, MOD - 2, MOD))\n )\n\n def __pow__(self, other):\n return (\n ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else\n ModInt(pow(self.x, other, MOD))\n )\n\n __radd__ = __add__\n\n def __rsub__(self, other):\n return (\n ModInt(other.x - self.x) if isinstance(other, ModInt) else\n ModInt(other - self.x)\n )\n\n __rmul__ = __mul__\n\n def __rtruediv__(self, other):\n return (\n ModInt(\n other.x * pow(self.x, MOD - 2, MOD)\n ) if isinstance(other, ModInt) else\n ModInt(other * pow(self.x, MOD - 2, MOD))\n )\n\n def __rpow__(self, other):\n return (\n ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else\n ModInt(pow(other, self.x, MOD))\n )\n\n\nn, a, b = map(int, input().split())\n\n\ndef f(p):\n if p == 0:\n return ModInt(1)\n if p % 2 == 0:\n t = f(p // 2)\n return t * t\n return 2 * f(p // 2)\n\n\nnC = [ModInt(1)]\nfor i in range(1, 200005):\n nC.append(nC[-1] * (n - i + 1) / i)\nprint(nC[-10:])\n\nprint((f(n) - nC[a] - nC[b] - 1))\n', 'MOD = 10 ** 9 + 7\n\n\nclass ModInt:\n def __init__(self, x):\n self.x = x % MOD\n\n def __str__(self):\n return str(self.x)\n\n __repr__ = __str__\n\n def __add__(self, other):\n return (\n ModInt(self.x + other.x) if isinstance(other, ModInt) else\n ModInt(self.x + other)\n )\n\n def __sub__(self, other):\n return (\n ModInt(self.x - other.x) if isinstance(other, ModInt) else\n ModInt(self.x - other)\n )\n\n def __mul__(self, other):\n return (\n ModInt(self.x * other.x) if isinstance(other, ModInt) else\n ModInt(self.x * other)\n )\n\n def __truediv__(self, other):\n return (\n ModInt(\n self.x * pow(other.x, MOD - 2, MOD)\n ) if isinstance(other, ModInt) else\n ModInt(self.x * pow(other, MOD - 2, MOD))\n )\n\n def __pow__(self, other):\n return (\n ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else\n ModInt(pow(self.x, other, MOD))\n )\n\n __radd__ = __add__\n\n def __rsub__(self, other):\n return (\n ModInt(other.x - self.x) if isinstance(other, ModInt) else\n ModInt(other - self.x)\n )\n\n __rmul__ = __mul__\n\n def __rtruediv__(self, other):\n return (\n ModInt(\n other.x * pow(self.x, MOD - 2, MOD)\n ) if isinstance(other, ModInt) else\n ModInt(other * pow(self.x, MOD - 2, MOD))\n )\n\n def __rpow__(self, other):\n return (\n ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else\n ModInt(pow(other, self.x, MOD))\n )\n\n\nn, a, b = map(int, input().split())\n\n\ndef f(p):\n if p == 0:\n return ModInt(1)\n if p % 2 == 0:\n t = f(p // 2)\n return t * t\n return 2 * f(p // 2)\n\n\nnC = [ModInt(1)]\nfor i in range(1, 200005):\n nC.append(nC[-1] * (n - i + 1) / i)\n# print(nC[-10:])\n\nprint((f(n) - nC[a] - nC[b]))\n', 'MOD = 10 ** 9 + 7\n\n\nclass ModInt:\n\n def __init__(self, x):\n self.x = x.x if isinstance(x, ModInt) else x % MOD\n\n def __str__(self): return str(self.x)\n __repr__ = __str__\n\n def __int__(self): return self.x\n __index__ = __int__\n\n def __add__(self, other): return ModInt(self.x + ModInt(other).x)\n\n def __sub__(self, other): return ModInt(self.x - ModInt(other).x)\n\n def __mul__(self, other): return ModInt(self.x * ModInt(other).x)\n\n def __pow__(self, other): return ModInt(pow(self.x, ModInt(other).x, MOD))\n\n def __truediv__(self, other): return ModInt(\n self.x * pow(ModInt(other).x, MOD - 2, MOD))\n\n def __floordiv__(self, other): return ModInt(self.x // ModInt(other).x)\n\n def __radd__(self, other): return ModInt(other + self.x)\n\n def __rsub__(self, other): return ModInt(other - self.x)\n\n def __rpow__(self, other): return ModInt(pow(other, self.x, MOD))\n\n def __rmul__(self, other): return ModInt(other * self.x)\n\n def __rtruediv__(self, other): return ModInt(\n other * pow(self.x, MOD - 2, MOD))\n\n def __rfloordiv__(self, other): return ModInt(other // self.x)\n\n def __lt__(self, other): return self.x < ModInt(other).x\n\n def __gt__(self, other): return self.x > ModInt(other).x\n\n def __le__(self, other): return self.x <= ModInt(other).x\n\n def __ge__(self, other): return self.x >= ModInt(other).x\n\n def __eq__(self, other): return self.x == ModInt(other).x\n\n def __ne__(self, other): return self.x != ModInt(other).x\n\n\ndef cmb(n, r): # nCr = n!/(n-r)!r!\n retVal = ModInt(1)\n for i in range(n-r+1, n+1):\n retVal *= i\n for i in range(2, r+1):\n retVal /= i\n return retVal\n\n\nn, a, b = map(int, input().split())\n\n\ndef twopow(p):\n if p == 0:\n return ModInt(1)\n if p % 2 == 0:\n t = twopow(p // 2)\n return t * t\n return 2 * twopow(p - 1)\n\n\nnC = [ModInt(1)]\nfor i in range(1, 200005):\n nC.append(nC[-1] * (n - i + 1) / i)\n\nprint((twopow(n) - nC[a] - nC[b] - 1))\n# print((twopow(n) - cmb(n, a) - cmb(n, b)-1))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s088651855', 's508629318', 's146791846']
[44112.0, 44112.0, 44120.0]
[1342.0, 1336.0, 1559.0]
[2018, 2016, 2060]
p02768
u744920373
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for _ in range(j)]\ndef dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))\n\n\ndef pow_r_mod(x:int, n:int, mod=10**9+7)->int:\n \n if n == 0:\n return 1\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x\n x *= x\n x %= mod\n n //= 2\n return (K * x) % mod\n\nm, a, b = mi()\n\nP = 10**9+7\nN = 2*(10**5)+1\ninv_t = [0]+[1]\n\x08\nfor i in range(2, N):\n inv_t += [inv_t[P % i] * (P - int(P / i)) % P]\n\nmca = mcb = 1\n\nfor i in range(1, a+1):\n mca *= (m-i+1) * inv_t[i]\n mca %= P\n\nmcb = mca\n\nfor i in range(a+1, b+1):\n mcb *= (m-i+1) * inv_t[i]\n mcb %= P\n\nprint((pow_r_mod(2, m)-1-mca-mcb) % P)', 'def mpow(x: int, k: int, MOD=1000000007) -> int:\n \n res = 1\n y = x\n while (k):\n if(k % 2 == 1):\n res = (res * y) % MOD\n y = (y ** 2) % MOD\n k = k // 2\n return res\n\nmod = 10**9+7 \n\nN, a, b = map(int,input().split())\n\nprint(mpow(2,10**9))\n\nnum = 1000000000 + 7\n\nMAX_NUM = N\nMOD = 10**9+7\n\nfac = [0 for _ in range(MAX_NUM)]\nfinv = [0 for _ in range(MAX_NUM)]\ninv = [0 for _ in range(MAX_NUM)]\n\nfac[0] = fac[1] = 1\nfinv[0] = finv[1] = 1\ninv[1] = 1\n\nfor i in range(2,MAX_NUM):\n fac[i] = fac[i-1] * i % MOD\n inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD\n finv[i] = finv[i-1] * inv[i] % MOD\n\ndef cmb(n,k):\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD\n\n#print(mpow(2,N))\n\nprint(mpow(2,N)- cmb(N, a) - cmb(N, b) -1)', 'import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for _ in range(j)]\ndef dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))\n\ndef table(n:int, p=10**9+7):\n global fact, factinv, inv\n fact = [1, 1]\n factinv = [1, 1]\n inv = [0, 1]\n for i in range(2, n+1):\n #fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n #factinv.append((factinv[-1] * inv[-1]) % p)\n\nm, a, b = mi()\n\nP = 10**9+7\nN = 2*(10**5)\ntable(N)\n\nmca = bunshi= 1\nfor i in range(1, a+1):\n \n mca *= (m-i+1)\n bunshi *= i \n mca %= P\n bunshi %= P\nmcb = mca\nmca = mca * pow(bunshi, P-2, P)\nmca %= P\n\nfor i in range(a+1, b+1):\n #mcb *= (m-i+1) * inv[i]\n mcb *= (m-i+1)\n bunshi *= i \n mcb %= P\n bunshi %= P\nmcb = mcb * pow(bunshi, P-2, P)\nmcb %= P\n\nprint((pow(2, m, P)-1-mca-mcb) % P)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s424174867', 's930971680', 's394251775']
[3064.0, 531096.0, 11052.0]
[18.0, 2132.0, 206.0]
[1204, 1265, 1312]
p02768
u765865533
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['mod=10 ** 9 + 7\n\nn, a, b = map(int, input().split())\n\ndef power(x,n):\n if n==0:\n return 1\n elif n%2==0:\n half=power2(x,n//2)\n return half**2 %mod\n else:\n half=power2(x,(n-1)//2)\n return half**2 * x %mod\n\ndef binomial(n,k):\n x=1\n y=1\n for i in range(k):\n x=x*(n-i)%mod\n y=y*(i+1)%mod\n return x*pow(y,mod-2,mod)%mod\n\nans=(power(2,n) - binomial(n,a) -binomial(n,b))%mod\n\nprint(ans)', 'mod=10 ** 9 + 7\n\nn, a, b = map(int, input().split())\n\ndef power(x,n):\n if n==0:\n return 1\n elif n%2==0:\n half=power(x,n//2)\n return half**2 %mod\n else:\n half=power(x,(n-1)//2)\n return half**2 * x %mod\n\ndef binomial(n,k):\n x=1\n y=1\n for i in range(k):\n x=x*(n-i)%mod\n y=y*(i+1)%mod\n return x*power(y,mod-2)%mod\n\nans=(power(2,n)-1 - binomial(n,a) -binomial(n,b))%mod\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s511483039', 's921356135']
[3064.0, 3064.0]
[22.0, 150.0]
[449, 447]
p02768
u767664985
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\np = 10 ** 9 + 7\nN = 10 ** 9 \nfact = [1, 1] # fact[n] = (n! mod p)\nfactinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)\ninv = [0, 1] \n\nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % p)\n inv.append((-inv[p % i] * (p // i)) % p)\n factinv.append((factinv[-1] * inv[-1]) % p)\n\nn, a, b = map(int, input().split())\nans = 2**n % p - 1\nans -= cmb(n, a, p) + cmb(n, b, p)\nprint(ans % p)\n', 'from functools import reduce\n\ndef cmb(n, r, p):\n r = min(n - r, r)\n if r == 0:\n return 1\n numer = reduce(lambda x, y: (x*y)%p, range(n, n - r, -1))\n denom = reduce(lambda x, y: (x*y)%p, range(1, r + 1))\n return (numer * pow(denom, p-2, p)) % p\n\np = 10 ** 9 + 7\nn, a, b = map(int, input().split())\n\nans = pow(2, n, p) - 1\nans -= cmb(n, a, p) + cmb(n, b, p)\nprint(ans % p)\n']
['Time Limit Exceeded', 'Accepted']
['s141886067', 's743071203']
[230392.0, 3572.0]
[2119.0, 157.0]
[585, 393]
p02768
u780962115
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b=map(int,input().split())\n\nmod=10**9+7\n\nJ=pow(2,n)%mod\ndef find_power(n,mod):\n \n powlist=[0]*(n+1)\n powlist[0]=1\n powlist[1]=1\n for i in range(2,n+1):\n powlist[i]=powlist[i-1]*i%(mod)\n return powlist\n\ndef find_inv_power(n):\n \n powlist=find_power(n,10**9+7)\n check=powlist[-1]\n first=1\n uselist=[0]*(n+1)\n secondlist=[0]*30\n secondlist[0]=check\n secondlist[1]=check**2\n for i in range(28):\n secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)\n a=format(10**9+5,"b")\n for j in range(30):\n if a[29-j]=="1":\n first=(first*secondlist[j])%(10**9+7)\n uselist[n]=first\n for i in range(n,0,-1):\n uselist[i-1]=(uselist[i]*i)%(10**9+7)\n return uselist\n\nC=find_inv_power(2*10**5+100)\nif True:\n c=1\n for i in range(a):\n c*=(n-i)\n c=c%mod\n c=c*C[a]\n c=c%mod\n d=1\n for i in range(b):\n d*=(n-i)\n d=d%mod\n d=d%mod\n d=d*C[b]\n print((J-c-d)%mod)\n', 'n,a,b=map(int,input().split())\n\nmod=10**9+7\n\ndef pow_cal(x,n,mod):\n if n==0:\n return 1\n elif n==1:\n return x%mod\n elif n>=2:\n if n%2==0:\n return (pow_cal(x,n//2,mod)**2)%mod\n else:\n return (x*pow_cal(x,n//2,mod)**2)%mod\n\ndef find_power(n,mod):\n \n powlist=[0]*(n+1)\n powlist[0]=1\n powlist[1]=1\n for i in range(2,n+1):\n powlist[i]=powlist[i-1]*i%(mod)\n return powlist\n\ndef find_inv_power(n,mod):\n \n c=1\n uselist=[0 for i in range(n+1)]\n for i in range(1,n+1):\n c*=i\n c%=mod\n first=pow_cal(c,mod-2,mod)\n uselist[n]=first\n for i in range(n,0,-1):\n uselist[i-1]=(uselist[i]*i)%(10**9+7)\n return uselist\nA=find_power(2*10**5,mod)\nB=find_inv_power(2*10**5,mod)\n\nd=pow_cal(2,n,mod)-1\np=1\nq=1\n\nfor i in range(1,a+1):\n p*=(n+1-i)\n p%=mod\n\np=p*B[a]%mod\n\nfor j in range(1,b+1):\n q*=(n+1-j)\n q%=mod\n\nq=q*B[b]%mod\n\nprint((d-p-q)%mod)']
['Wrong Answer', 'Accepted']
['s598860842', 's169810774']
[199460.0, 18996.0]
[2107.0, 264.0]
[1184, 1158]
p02768
u782748646
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['from math import factorial\n\ndef framod(n, mod, a=1):\n for i in range(1,n+1):\n a=a * i % mod\n return a\n\ndef power(n, r, mod):\n if r == 0: return 1\n if r%2 == 0:\n return power(n*n % mod, r//2, mod) % mod\n if r%2 == 1:\n return n * power(n, r-1, mod) % mod\n\ndef comb(n, k, mod):\n a=framod(n, mod)\n b=framod(k, mod)\n c=framod(n-k, mod)\n return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod\n\n\n\nn,a,b=map(int, input().split())\nmo=10**9+7\n\nfn=2*10**5\nfac=[0]*fn\nfac[1]=n\nfor i in range(2,fn):\n fac[i]=fac[i-1]*(n-i+1)*power(i, mo-2, mo) % mo\n\nprint((power(2, n, mo)-1-fac[a]-fac[b])%mo)', 'import time\nfrom math import factorial\n\ndef framod(n, mod, a=1):\n for i in range(1,n+1):\n a=a * i % mod\n return a\n\ndef power(n, r, mod):\n if r == 0: return 1\n if r%2 == 0:\n return power(n*n % mod, r//2, mod) % mod\n if r%2 == 1:\n return n * power(n, r-1, mod) % mod\n\ndef comb(n, k, mod):\n a=1\n for i in range(n, n-k, -1):\n a=a * i % mod\n b=framod(k, mod)\n return (a * power(b, mod-2, mod)) % mod\n\nn,a,b=map(int, input().split())\nmo=10**9+7\n\nfn=2*10**5\nfac=[0]*fn\nfac[1]=n\n\nprint((power(2, n, mo)-1-comb(n,a,mo)-comb(n,b,mo))%mo)\n\n\n']
['Time Limit Exceeded', 'Accepted']
['s502386489', 's707689776']
[10536.0, 4592.0]
[2104.0, 113.0]
[639, 585]
p02768
u786793781
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nfrom functools import reduce\nmod = 10**9+7\n\n\ndef nCk(n, k):\n # c = reduce(lambda x, y: x*y % mod, range(n, n-k, -1))\n # m = reduce(lambda x, y: x*y % mod, range(1, k+1))\n c = reduce(lambda x, y: x*y % mod, range(n, n-k+1, -1))\n m = reduce(lambda x, y: x*y % mod, range(1, k))\n return c*pow(m, mod-2, mod) % mod\n\n\nn, a, b = map(int, input().split())\n\nans = pow(2, n, mod) - nCk(n, a) - nCk(n, b) - 1\nans %= mod\nprint(ans)\n', '#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nfrom functools import reduce\nmod = 10**9+7\n\nn, a, b = map(int, input().split())\n\n\ndef nCk(n, k):\n numer = reduce(lambda x, y: (x * y) % mod, range(n, n - k, -1))\n denom = reduce(lambda x, y: (x * y) % mod, range(1, k + 1))\n return numer * pow(denom, mod - 2, mod) % mod\n\n\nans = pow(2, n, mod) - nCk(n, a) - nCk(n, b) - 1\nans %= mod\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s451006335', 's006354965']
[3572.0, 3572.0]
[159.0, 159.0]
[484, 400]
p02768
u797572808
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n,a,b = map(int,input().split())\n\nfac = [0 for _ in range(n+1)]\ninv = [0 for _ in range(n+1)]\nfinv = [0 for _ in range(n+1)]\n\nfac[0] =fac[1]= 1\ninv[0] =inv[1]= 1\nfinv[0] = finv[1] = 1\n\np = 10**9 + 7\n#p = 31\n#inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;\nfor i in range(2,n+1):\n fac[i] = (fac[i-1]*i)%p\n inv[i] = (p - inv[p%i]*int(p/i)%p)%p\n finv[i] = (finv[i-1]*inv[i])%p\n \n#print(fac)\n#print(inv)\n#print(finv)\n\ndef cal(m,k):\n return fac[m]*(finv[k]*finv[m-k]%p)%p\n\nans=pow(2,n,mod) - 1\nans = (ans - cal(n,a) - cal(n,b))%p\n\nif(ans<0):\n ans = -1*ans\n\nprint(ans)', 'import math\n\nn,a,b = map(int,input().split())\n\np = 10**9 + 7\n\n\ndef cmb(n, r):\n total = 1\n for i in range(r):\n total = total * (n - i) % p\n \n return total * pow(math.factorial(r), p - 2, p) % p\n\ntotal = pow(2, n, p)-1\na_total = cmb(n, a)\nb_total = cmb(n, b)\nprint((total - a_total - b_total) % p)']
['Runtime Error', 'Accepted']
['s734480804', 's154491132']
[516504.0, 5440.0]
[2123.0, 1505.0]
[577, 318]
p02768
u809816772
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['n, a, b = map(int, input().split())\nlaw = 10 ** 9 + 7\n\ndef fermat(n, r, law):\n x = 1\n y = 1\n for i in range(r):\n x = x * (n - i) % law\n y = y * (i + 1) % law\n\n ans = x * pow(y, law - 2, law)\n return ans\n\nprint((pow(2,n,law)- fermat(n,a,law)-fermat(n,b,law))%law)', 'n, a, b = map(int, input().split())\nlaw = 10 ** 9 + 7\n\ndef fermat(n, r, law):\n x = 1\n y = 1\n for i in range(r):\n x = x * (n - i) % law\n y = y * (i + 1) % law\n\n ans = x * pow(y, law - 2, law)\n return ans\n\nprint((pow(2,n,law)- fermat(n,a,law)-fermat(n,b,law))%law)', 'n, a, b = map(int, input().split())\nlaw = 10 ** 9 + 7\n\ndef fermat(n, r, law):\n x = 1\n y = 1\n for i in range(r):\n x = x * (n - i) % law\n y = y * (i + 1) % law\n\n ans = x * pow(y, law - 2, law) % law\n return ans\n\nprint((pow(2,n,law)- fermat(n,a,law)-fermat(n,b,law)-1)%law)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s309819843', 's648931575', 's762407383']
[3064.0, 3064.0, 3064.0]
[144.0, 143.0, 144.0]
[291, 291, 299]
p02768
u813098295
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['# return x^{-1} % mod\n# it take O(log{mod})\ndef mod_inverse(x, mod):\n return pow(x, mod-2, mod)\n\n# return nCk % mod\n# it take O(k)\ndef mod_comb(n, k, mod):\n numer, denom = 1, 1\n for i in range(k):\n \n numer = numer * ((n-i) % mod) % mod\n denom = denom * ((i+1) % mod) % mod\n\n return numer * mod_inverse(denom) % mod\n\nn, a, b = map(int, input().split())\nans = pow(2, n, mod) - 1\nans = (ans - mod_comb(n, a, mod)) % mod\nans = (ans - mod_comb(n, b, mod)) % mod\nprint( (ans + mod) % mod )\n', 'def mod_inverse(x, mod):\n return pow(x, mod - 2, mod)\n\n\n# return nCk % mod\n# it takes O(k)\ndef mod_comb(n, k, mod):\n numer, denom = 1, 1\n for i in range(k):\n numer = numer * ((n - i) % mod) % mod\n denom = denom * ((i + 1) % mod) % mod\n\n return numer * mod_inverse(denom, mod) % mod\n\n\nmod = 10**9 + 7\nn, a, b = map(int, input().split())\n\nans = pow(2, n, mod) - 1\nans = (ans - mod_comb(n, a, mod)) % mod\nans = (ans - mod_comb(n, b, mod)) % mod\nans = (ans + mod) % mod\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s184528938', 's092233739']
[3064.0, 3064.0]
[19.0, 155.0]
[547, 503]
p02768
u825541307
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['mod = 10**9 + 7\nN = 10**9\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\n\nfor i in range(2, N + 1):\n\tg1.append((g1[-1] * i) % mod)\n\tinverse.append((-inverse[mod % i] * (mod // i)) % mod)\n\tg2.append((g2[-1] * inverse[-1]) % mod)\n\ndef cmb(n, r, mod):\n\tif r < 0 or r > n:\n\t\treturn 0\n\tr = min(r, n-r)\n\treturn g1[n] * g2[r] * g2[n - r] % mod\n\n\nn,a,b = map(int,input().split())\n#mod = 10**9+7\n\n#print(cmb(n,a) % mod)\n#print(cmb(n,b) % mod)\nprint((2**n - 1 - cmb(n,a,mod) - cmb(n,b,mod)) % mod)', 'def cmb(n, r):\n\tif n - r < r:\n\t\tr = n - r\n\tif r == 0:\n\t\treturn 1\n\tif r == 1:\n\t\treturn n\n\t\n\tnum = [n - r + k + 1 for k in range(r)] \n\tden = [k + 1 for k in range(r)] \n\t\n\tfor p in range(2, r + 1):\n\t\tpivot = den[p - 1]\n\t\tif pivot > 1:\n\t\t\toffset = (n - r) % p\n\t\t\tfor k in range(p - 1, r, p):\n\t\t\t\tnum[k - offset] /= pivot\n\t\t\t\tden[k] /= pivot\n\t\n\tresult = 1\n\tfor k in range(r):\n\t\tif num[k] > 1:\n\t\t\tresult *= int(num[k])\n\t\t\tresult = result % mod\n\t\n\treturn result\n\nn,a,b = map(int,input().split())\nmod = 10**9+7\n\nprint((pow(2,n,mod) - 1 - cmb(n,a) - cmb(n,b)) % mod)']
['Time Limit Exceeded', 'Accepted']
['s038190735', 's883628953']
[228700.0, 27700.0]
[2120.0, 660.0]
[481, 595]
p02768
u836311327
2,000
1,048,576
Akari has n kinds of flowers, one of each kind. She is going to choose one or more of these flowers to make a bouquet. However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b. How many different bouquets are there that Akari can make? Find the count modulo (10^9 + 7). Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.
['def per(n, r, mod=10**9+7): \n per = 1\n for i in range(r):\n per = per*(n-i) % mod\n return per\n\n\ndef com(n, r, mod=10**9+7): \n bunshi = per(n, r, mod)\n bunbo = 1\n for i in range(1, r+1):\n bunbo = bunbo*i % mod\n return bunshi*pow(bunbo, -1, mod)\n\n\nn, a, b = map(int, input().split())\n \nans = pow(2,n,10**9+7)\n\nprint(ans-com(n,a)-com(n,b))', 'def per(n, r, mod=10**9+7): \n per = 1\n for i in range(r):\n per = per*(n-i) % mod\n return per\n \n \ndef com(n, r, mod=10**9+7): \n bunshi = per(n, r, mod)\n bunbo = 1\n for i in range(1, r+1):\n bunbo = bunbo*i % mod\n return bunshi*pow(bunbo, -1, mod)\n \n \nn, a, b = map(int, input().split())\n \nans = pow(2,n,10**9+7)\n \nprint(ans-com(n,a)-com(n,b)-1)', 'def per(n, r, mod=10**9+7): \n per = 1\n for i in range(r):\n per = per*(n-i) % mod\n return per\n \n \ndef com(n, r, mod=10**9+7): \n bunshi = per(n, r, mod)\n bunbo = 1\n for i in range(1, r+1):\n bunbo = bunbo*i % mod\n return bunshi*pow(bunbo, -1, mod)%mod\n \n \nn, a, b = map(int, input().split())\n \nans = pow(2,n,10**9+7)\n \nprint((ans-com(n,a)-com(n,b)-1)%(10**9+7))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s204575216', 's495087886', 's664640349']
[9060.0, 9212.0, 9084.0]
[108.0, 115.0, 115.0]
[403, 410, 426]