Problem:


Score : 400 points

Problem Statement

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.

Constraints

All values in input are integers.

2 \leq n \leq 10^9

1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5)

Input

Input is given from Standard Input in the following format:

n a b

Output

Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)

Sample Input 1

4 1 3

Sample Output 1

7

In this case, Akari can choose 2 or 4 flowers to make the bouquet.

There are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.

Sample Input 2

1000000000 141421 173205

Sample Output 2

34076506

Print the count modulo (10^9 + 7).



Sample input:
4 1 3


Sample output:
7

Submission status: Runtime Error

Solution code:
n, a ,b = map(int, input().split())

mod = 1000000007
width = 1000
table = [ 1, 128233642, 993191796, 246084337, 175673566, 883787401, 470931556, 119995528, 225567908, 757928892, 250015370, 913979655, 754758, 207715304, 680281231, 630322311, 642314838, 834078844, 599226039, 918470969, 777847830, 188150013, 936569805, 609321015, 803755964, 506567627, 733034722, 525152703, 125374323, 229063893, 64381203, 331225140, 239876153, 938119791, 238030663, 963888220, 269540267, 288849729, 868543185, 176093029, 129227219, 57384053, 510217116, 42904984, 1283621, 229119361, 122050053, 83923714, 99441611, 723598838, 664720426, 824990192, 899870337, 994461247, 78470227, 616312139, 585511607, 457301297, 774218347, 24761471, 220551652, 797724439, 42696969, 433164019, 825454299, 183907026, 881797659, 823559228, 703904407, 624713517, 805011386, 175293956, 157911929, 315160646, 59387184, 711105445, 710926865, 239798930, 734168782, 513146799, 71626953, 883937988, 613778426, 107738376, 960564286, 84887701, 771212964, 71595332, 319321717, 980960223, 368173468, 67320689, 862499851, 864972828, 48646097, 670160814, 725736339, 790163830, 663423088, 255691818, 388742192, 305094892, 522669454, 472392039, 946047214, 445919328, 748072600, 923340633, 932008794, 641127822, 633943807, 473400148, 55310953, 397250219, 468376442, 583215176, 797665328, 890028978, 528044431, 795787957, 546160751, 21487680, 168379396, 292434098, 414672346, 74193376, 460353865, 599810935, 250857617, 915366231, 248863345, 970381475, 792991318, 740333468, 505276601, 404393468, 273222696, 38135257, 776858195, 153730583, 642800490, 383597969, 352113689, 326414281, 751880110, 401720832, 321560177, 799699361, 847915310, 122391227, 227253170, 943226946, 628558171, 741676814, 471158688, 954631869, 493837145, 558658912, 420443735, 350090863, 217956259, 331145950, 853718873, 294871436, 441691230, 450998982, 237913344, 891941663, 1946260, 405112401, 448399780, 134526127, 246436561, 278169858, 460138465, 93785028, 536128669, 614812564, 895531956, 53159706, 343122361, 979426864, 535308676, 821698590, 111592160, 392955473, 447760971, 209213748, 847593978, 203062304, 203128902, 787544197, 498828478, 184919578, 105720019, 69934934, 13384364, 973282740, 449768173, 269308198, 904824556, 182396273, 584885733, 396642025, 609732757, 302161309, 183805719, 163566228, 479978003, 98799651, 976400196, 125377402, 799132752, 870397588, 644664934, 129577634, 690319271, 611331587, 653433224, 140236662, 409788350, 991717810, 62680229, 190864441, 36959486, 149551212, 850748843, 164689931, 861991239, 929807057, 969665321, 847381024, 849985007, 211790079, 300573111, 274608474, 852794964, 947517699, 845476998, 892993251, 942841378, 752521136, 160135971, 872092879, 947081586, 43872472, 699047819, 356785202, 852607095, 799881153, 78633765, 743118036, 270375915, 917589851, 68917553, 710229437, 55629368, 618076743, 280545717, 675792083, 46429647, 151769255, 451990910, 175101818, 843430958, 38053664, 646697534, 23357308, 206681493, 888773710, 419288563, 102196642, 166544838, 158026445, 853567157, 547481582, 271969574, 391772235, 700892631, 483230045, 622773713, 745587272, 464843479, 112408178, 48833532, 419683777, 357283581, 893210864, 753476511, 49462239, 43950471, 623405550, 245081995, 772845334, 469206379, 631437749, 684644905, 793794697, 569684184, 860006640, 158036420, 392172613, 162031808, 602247245, 203070433, 384809257, 29972101, 344657818, 105304879, 159934700, 539867530, 111755839, 775104266, 722056100, 480533881, 603649910, 730015093, 32522487, 687171713, 684911737, 629028067, 75924301, 327784991, 613277615, 911404085, 68597770, 92366073, 745625029, 473314335, 507714509, 98679775, 522660661, 475294170, 305900432, 650978491, 240960675, 954022341, 297423873, 233051932, 288347091, 181067811, 822741050, 72596087, 389928500, 925730861, 660630476, 418823335, 494735470, 956973216, 280787188, 577131628, 195596415, 780760749, 646964034, 492636384, 290950928, 665101198, 971833316, 402869341, 31542354, 448714637, 853057984, 859647481, 659285587, 703667161, 442458694, 57325142, 151885002, 151752857, 953328299, 274699378, 797580192, 900864549, 977052491, 903191059, 560104200, 52364315, 317587469, 733519519, 51326765, 172718980, 394213323, 499127130, 125665101, 599958067, 570048626, 358205301, 955898164, 396169962, 863114450, 524877565, 561615134, 336979830, 751853389, 98033418, 914857313, 669594871, 233002010, 798378948, 353985696, 132400827, 853908795, 633800050, 114199369, 8366891, 369520637, 840068688, 154949227, 766964103, 1213933, 283566441, 213654982, 766431359, 140028557, 389857786, 592586116, 294866824, 626984599, 88266364, 960355422, 299777072, 159529372, 433368021, 546910609, 640482852, 176367836, 62590712, 619758852, 519471843, 689296297, 688241748, 125464096, 549853046, 180640016, 669655376, 304486472, 552708211, 641131096, 250145685, 522823788, 422054382, 614827289, 213695506, 564996794, 816097193, 472957326, 627305145, 419352923, 233618208, 201907686, 789638131, 935757716, 321551236, 258348634, 248012645, 915754672, 94217171, 566557194, 883879696, 841856794, 386613162, 570112346, 183700660, 278268556, 308943479, 160666387, 737303060, 567134616, 327727771, 639296326, 219084929, 949740710, 467443562, 16455771, 875530545, 782951703, 711107295, 863411295, 578371653, 66207956, 375238282, 908681407, 515884084, 90795523, 455372810, 89837046, 165491515, 545433366, 660354454, 653260780, 270146387, 283056775, 39236829, 89221906, 548284763, 958657863, 647273634, 738216290, 960141650, 192631043, 647619052, 435099529, 111019175, 387052722, 349026437, 943168803, 597199864, 798930903, 280032050, 191489048, 871756271, 864201473, 573902924, 776735804, 795907052, 513212481, 703258263, 151087418, 176917020, 492333520, 645927523, 842232145, 918613011, 167094468, 506609335, 871613850, 791653278, 688384948, 512230762, 466482156, 483519685, 433675444, 266224879, 712040274, 316470404, 6297629, 247528343, 266547054, 831469341, 917532298, 459833872, 954893577, 614837703, 484625452, 614869637, 917743182, 905427381, 449126127, 796820262, 408509829, 273602905, 130924280, 1363238, 389499824, 954805317, 932440256, 34161376, 646994455, 672836257, 808301053, 929096963, 231765547, 390778694, 403445961, 653868071, 549355895, 901843642, 882716412, 125812900, 266137390, 250231633, 801863164, 862419855, 603909210, 141087179, 919738330, 901776094, 636804992, 717115643, 982881315, 278589981, 897622715, 592874475, 963773361, 139945137, 389252372, 890252510, 865544569, 462018791, 972099566, 849449796, 319640588, 967009768, 977653667, 710029654, 805234475, 831002177, 275336330, 422855006, 949746887, 541794170, 641881338, 296285475, 292901421, 107561334, 338689309, 112458779, 325082011, 3976415, 304229218, 601214344, 86328828, 751441489, 862204727, 554702266, 186018851, 166853623, 545193868, 432626342, 498556538, 860331963, 609479011, 974179405, 836442658, 315554906, 589911857, 242364047, 745675667, 630588185, 96935486, 898831734, 753652548, 83905053, 205072787, 486649120, 696978729, 371086126, 376354590, 740911902, 983182992, 959047580, 971565881, 279013191, 628219669, 483423122, 559666181, 748528679, 349865602, 276254737, 103092679, 990713044, 883898451, 334011645, 643112778, 85592384, 110938911, 78761716, 162118715, 110215007, 361560450, 218658983, 958290706, 760866197, 29604925, 704254054, 884528885, 571553124, 722545849, 511824535, 189127084, 293444525, 539142876, 642675615, 952158794, 312246024, 275756454, 200298706, 261130169, 62294542, 510890694, 385243308, 87361521, 503202218, 685328461, 550921230, 668093102, 699944378, 251795690, 907314994, 834548983, 352821537, 549529635, 281274542, 587974019, 795434349, 753132255, 415545290, 77523025, 281787237, 176567548, 722869575, 34478434, 714412522, 671034944, 329114990, 958416239, 745926726, 754875902, 211334210, 513547036, 381109223, 400825307, 949915497, 794380771, 663920989, 690042117, 830304630, 901554891, 751723357, 837761558, 378511108, 115298175, 325447247, 614534142, 840758997, 813807256, 591333543, 691718994, 672655144, 699954263, 85458370, 19198497, 754433496, 300341823, 886939169, 54570137, 616323646, 496090306, 34402024, 817983914, 915965688, 479650439, 388452570, 454605978, 750397062, 559638074, 303896928, 22416828, 441748912, 635659640, 815695490, 812160395, 166688469, 740163360, 14049893, 284479436, 190422595, 187192515, 376697732, 47634513, 160874373, 126508400, 775997892, 99363239, 493832830, 763882002, 701596576, 15590851, 257335774, 894463993, 185206871, 441874230, 746700252, 302941806, 868371723, 139345496, 869630341, 144717208, 187345841, 866229903, 724450461, 648235214, 776271119, 672074506, 602185675, 656002752, 240125575, 759576687, 463430427, 24769850, 862837188, 53160078, 513987022, 118514895, 188179897, 699945777, 115323244, 199918423, 833621264, 805714018, 463715736, 180028074, 475829876, 235402877, 772103983, 49684084, 443337661, 655366896, 289638503, 258332145, 360855087, 899672361, 530502576, 801491866, 641986630, 940068353, 797422831, 378645901, 853709985, 87792814, 398991956, 660101704, 243383485, 532777074, 459644547, 702843272, 209971686, 829986137, 470834910, 246066405, 806738292, 39284371, 389133055, 321621467, 698830270, 670701663, 45171714, 633003395, 90710349, 967169522, 541775025, 988685463, 21712927, 170049523, 503374186, 602599325, 962557054, 800216315, 767004598, 737518012, 609437737, 530398437, 82759720, 621977664, 548979006, 245507299, 832068105, 80911832, 416356617, 318565618, 40420676, 412673617, 923197226, 594087420, 42029599, 521233968, 806698019, 833042288, 321490146, 468133703, 773978131, 414775293, 774760659, 300992794, 274025195, 445949927, 819855707, 528038317, 620344533, 51066611, 742263715, 539906647, 9185408, 244838920, 887410937, 539585878, 233938533, 832701367, 208941375, 890452341, 320097016, 460377592, 383972524, 956067685, 534451216, 946322067, 950977861, 379271132, 363268251, 740246294, 446595916, 554740081, 585267057, 666743526, 941443156, 923656781, 122441988, 203736886, 815895710, 498136156, 239856470, 992717436, 743674726, 96127672, 932528338, 278615623, 146992535, 68306453, 131167060, 272573946, 851897254, 782985541, 759971846, 767877668, 505054565, 682447171, 154820240, 351374909, 29839511, 846987109, 213673769, 590919567, 264042121, 189663389, 717706128, 781660659, 590772569, 670325982, 9239468, 791592672, 51083743, 740568821, 281574447, 587141513, 553122503, 340747559, 726765483, 771154066, 145504712, 464498808, 328555850, 866235034, 289880945, 310574040, 31723627, 26631855, 19526377, 58086236, 918654424, 582386705, 784853394, 657402015, 976196645, 154059840, 149978308, 600014675, 7004660, 658540583, 953807513, 842210720, 300038049, 525785906, 487155590, 970029619, 25074612, 511691999, 455850881, 892170974, 730230612, 811413348, 426045335, 640134437, 120756795, 527174688, 712332795, 372350239, 770574347, 775312159, 726265742, 117585021, 808434455, 150599746, 257106196, 676730440, 520558862, 38297346, 220183171, 564917745, 346371991, 627835740, 900198419 ]
def factrial(n):
    if n >= mod:
        return 0
    acc = table[n // (mod // width)]
    init = n // (mod // width) * (mod // width)
    for i in range(max(1, init), n+1):
        acc = acc * i % mod
    return acc

def power_func(a,n,p):
    bi=str(format(n,"b"))
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res

X = power_func(2,n,m)
X = X- 1
Y = (factrial(n)* pow(factrial(a),m-2,m)*pow(factrial(n-a),m-2,m)) % m
Z = (factrial(n)* pow(factrial(b),m-2,m)*pow(factrial(n-b),m-2,m)) % m
X = (X-Y + m) % m
X = (X-Z + m) % m
print(int(X))

Submission status: Runtime Error

Solution code:
from functools import reduce

def cmb(n, r, mod):
    r = min(r, n-r)
    num = reduce(lambda x, y: x * y % mod, range(n, n-r, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, r+1))
    return num * pow(den, mod-2, mod) % mod

n, a, b = map(int, input().split())
mod = 10**9 + 7

temp = pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)
ans = temp % mod

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a,b = map(int,input().split())
def sp(n):
  	if n == 1:
    	return 2
  	if n%2 == 0:
    	return (sp(n//2)**2)%(10**9+7)
	if n%2 == 1:
  	  return (2*sp(n-1))%(10**9+7)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


print((sp(n)-cmb(n,a,10**9+7)-cmb(n,b,10**9+7))%(10**9+7))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
#res = 2 ** n - 1
res = pow(2, n, mod)
mod = 10**9 + 7

def cmb(n, r, mod):
    r = min(n-r, r)
    if r == 0:
        return 1
    over, under = 1, 1
    for i in range(1, r+1):
        over = over * (n-i+1) % mod
        under = under * i % mod
    inv = pow(under, mod-2, mod)
    return over * inv % mod

res -= cmb(n,a,mod)
res -= cmb(n,b,mod)

print(res % mod)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())

mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

fac = [0]*(10**9+1)
fac[0] = 1
fac[1] = 1
for i in range(2,10**9+1):
    fac[i] = fac[i-1] * i % mod

c = pow(2,n,mod)
c -= 1
c -= ( fac[n] * modinv(fac[a]) )%mod * modinv(fac[n-a]) % mod
c -= (fac[n] * modinv(fac[b])) % mod * modinv(fac[n-b]) % mod
print(c%mod)

Submission status: Runtime Error

Solution code:
n = int(input())
a,b = map(int,input().split())
def sp(n):
  if n == 1:
    return 2
  if n%2 == 0:
    return (sp(n//2)**2)%(10**9+7)
  if n%2 == 1:
    return (2*sp(n-1))%(10**9+7)
def com(n,a):
  if a == 1:
    return n
  return (com(n-1,a-1)+com(n-1,a))%(10**9+7)
print((sp(n)-com(n,a)-com(n,b))%(10**9+7))

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())

mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

fac = [0]*(n+1)
fac[0] = 1
fac[1] = 1
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod
    
c = pow(2,n,mod)
c -= 1
c -= ( fac[n] * modinv(fac[a]) )%mod * modinv(fac[n-a]) % mod
c -= (fac[n] * modinv(fac[b])) % mod * modinv(fac[n-b]) % mod
print(c%mod)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
res = 2 ** n - 1

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

res -= cmb(n,a,mod)
res -= cmb(n,b,mod)

print(res)

Submission status: Runtime Error

Solution code:
def comb(n, r):
    if r<0 or r>n:
        return 0
    r=min(r, n-r)
    return g1[n]*g2[r]*g2[n-r]%MOD

MOD=10**9+7
MAXN=200000+10
g1=[1, 1]
g2=[1, 1]
inverse=[0, 1]

for i in range(2, MAXN+1):
    g1.append((g1[-1]*i)%MOD)
    inverse.append(-inverse[MOD%i]*(MOD//i)%MOD)
    g2.append((g2[-1]*inverse[-1])%MOD)

def binary(n):
    return bin(n)[2:]

def pow_by_binary_exponentiation(a, x):
    x=[int(b) for b in binary(x)]
    y=a
    for i in range(1, len(x)):
        y=(y**2)%MOD
        if x[i]==1:
            y=(y*a)%MOD
    return y

N, A, B=map(int, input().split())
ans=pow_by_binary_exponentiation(2, N)-comb(N, A)-comb(N, B)-1
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,a,b= map(int, input().split())
mod = 10 ** 9 + 7
def power_func(a,n,mod):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %mod
    if bi[i]=="1":
      res=(res*a) %mod
  return res


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r=min(r,n-r)

    return g1[n] * g2[r] * g2[n - r] % mod


N =10 ** 6 # 出力の制限
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

ans=(power_func(2,n,mod)-1-cmb(n,a,mod)-cmb(n,b,mod))%mod
print(ans)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

if __name__=="__main__":
    n, a, b = map(int, input().split())

    #ans = 2**n - int(comb(n,a)) - int(comb(n,b)) - 1
    ans = 2**n - comb(n,a, exact=True) - comb(n,b, exact=True) - 1

    print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
import factorial from math
n,a,b = map(int,input().split())

mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)


c = pow(2,n,mod)
c -= 1
c -= ( factorial(n) * modinv(factorial(a)) )%mod * modinv(factorial(n-a)) % mod
c -= ( factorial(n) * modinv(factorial(b)) )%mod * modinv(factorial(n-b)) % mod
print(c%mod)

Submission status: Runtime Error

Solution code:
# coding: utf-8

# from math import factorial as fact

n, a, b = map(int, input().split())


def cnk(n, k, a):
    output = 1
    if k > n-k:
        k = n-k

    for i in range(1, k+1):
        output *= (n-k+1)//k
        if i == a:
            output_a = output

    return output_a, output


cnk_a, cnk_b = cnk(n, b, a)

# print(cnk(10**8, 2 * 10**5) % (10**9 + 7) )
print((2**n) - 1 - (cnk_a + cnk_b) % (10**9 + 7))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
mo = 10 ** 9 + 7
def hanaya(n, x):
    if x == 1:
        return n
    else:
        return (((hanaya(n, x-1))*((n-x+1)/x))%mo)

ans = (pow(2, N, mo) - 1 - hanaya(N, A)- hanaya(N, B)) % mo
print(int(ans))

Submission status: Runtime Error

Solution code:
def pow2(n, mod):
    p = 2
    r = 1
    while n:
        if n % 2:
            r = r * p % mod
        p = (p * p) % mod
        n //= 2
    return r

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def nCr(n, r, mod):
    t = 1
    r = min(r, n - r)
    for i in range(n - r + 1, n + 1):
        t = t * i % mod
    return t * g2[r] % mod



def prep(n, mod):
    for i in range(2, n):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

def main():
    n, a, b = list(map(int, input().split()))
    aod = 10 ** 9 + 7
    prep(2 * (10 ** 5), mod)
    print((pow2(n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod))% mod)


main()

Submission status: Runtime Error

Solution code:
import math

#def comb_old(N,R):
#    return int(math.factorial(N))/int(math.factorial(N-R))/int(math.factorial(R))   

def comb(N,R):
    c = 1
    for i in range(N-R+1,N+1):
        c = c*i

    for i in range(2,R+1):
        c = c/i

    return c

if __name__=="__main__":
    n, a, b = map(int, input().split())

    ans = 2**n - int(comb(n,a)) - int(comb(n,b)) - 1

    print(ans % 1000000007)

Submission status: Runtime Error

Solution code:
def cmb(n, r, mod):
    c=1
    for i in range(1, r+1):
        c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod
    return c

n, a, b = map(int, inputs[0]().split())
MOD = 10**9 + 7
print((pow(2, n, MOD) - cmb(n, a, MOD) - cmb(n, b, MOD) - 1) % MOD)

Submission status: Runtime Error

Solution code:
from scipy.special import comb
n,a,b=map(int,input().split())
MOD=10**9+7
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans

na=comb(n,a)
nb=comb(n,b)

ans=(pos(2,n,MOD)-na-nb-1)%MOD

print(ans)

Submission status: Runtime Error

Solution code:
def comb(n, r, mod=10**9 + 7):
    c=1
    for i in range(1, r+1):
        c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod
    return c

n, a, b = map(int, input().split())
print((pow(2, n, MOD) - cmb(n, a) - cmb(n, b) - 1) % MOD)

Submission status: Runtime Error

Solution code:
from math import factorial

n, a, b = map(int, input().split())

combinations = 0

for i in range(n):
    if (i != a) and (i != b):
        combinations += (factorial(n) / factorial(i+1) / factorial(n - (i+1)) % (10 ** 9 + 7)

print(int(combinations % (10 ** 9 + 7)))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
ans=2**n-1
n1=1
n2=1
for i in range(a):
    n1*=n-i
    n1/=i+1
for j in range(b):
    n2*=n-i
    n2/=i+1
print(int(ans-n1-n2))

Submission status: Runtime Error

Solution code:
def conbi(n, r):
    return factorial(n) // (factorial(n - r)*factorial(r))
def main():
  N,a,b=map(int,input().split())
  from math import factorial  
  total=(2**N)-1
  A=conbi(N,a)
  B=conbi(N,b)
  ans=(total-A-B)%1000000007
  print(ans)
if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

mod = 10 ** 9 + 7

def resolve():
    N, a, b = iim()

    ans = 0
    c1 = 1
    for i in range(n):
        c1 *= (n -i) // (i + 1)
        if i in (a, b):
            pass
        ans += c1

    print(ans % mod)

if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:

import math
import itertools

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    ret = 0
    n_all = 0
    for i in range(n):
        n_all += len(list(itertools.combinations(list(range(n)), i)))
    n_all -= len(list(itertools.combinations(list(range(n)), a)))
    n_all -= len(list(itertools.combinations(list(range(n)), b)))
    x = 10**9 + 7
    ret = n_all % x
    print(ret)

Submission status: Runtime Error

Solution code:
m = 10**9+7
def power(x,y,m):
    if y==0:
        return 1
    if y==1:
        return x%m
    if y%2==0:
        return power((x*x)%m,y//2,m)
    return ((x%m)*power((x*x)%m,y//2,m))%m
def n_c_r(n,r,m):
  	s = 1
    for i in range(1,n-r+1):
      	s = (s*(r+i)//i)
    return s%m
N,a,b = map(int, input().split())
ans = (((power(2,N,m)+m)%m) -(n_c_r(N,max(N-a,a),m) + n_c_r(N,max(N-b,b),m)))%m
print(ans)

Submission status: Runtime Error

Solution code:
N, a, b = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
X = 2 * (10**5)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, X + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print(pow(2, N)%mod - ax - bx - 1)

Submission status: Runtime Error

Solution code:
from functools import lru_cache

@lru_cache(maxsize=1000000)
def fact(n):
  if n <= 1:
    return 1
  return fact(n-1) * n

def comb(n,r):
    return fact(n) // fact(n-r) // fact(r)

n, a, b = map(int, input().split())

ans = (2 ** n - 1) - comb(n, a) - comb(n, b)
ans = ans % (10 ** 9 + 7)
print(ans)

Submission status: Runtime Error

Solution code:
def pow2(n, mod):
    p = 2
    r = 1
    while n:
        if n % 2:
            r = r * p % mod
        p = (p * p) % mod
        n //= 2
    return r

g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def nCr(n, r, mod):
    t = 1
    for i in range(n - r + 1, n + 1):
        t = t * i % mod
    return t * g2[r] % mod



def prep(n, mod):
    for i in range(2, n):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)

def main():
    n, a, b = list(map(int, input().split()))
    mod = 10 ** 9 + 7
    prep(2 * (10 ** 5), mod)
    print((pow2(n, mod) - 1 - nCr(n, a, mod) - nCr(n, b, mod))% mod)


main()

Submission status: Runtime Error

Solution code:
n,a,b=map(int, input().split())

def cmb(n, r, mod):
    if (r<0 or r>n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**4
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
    
A=cmb(n,a,mod)
B=cmb(n,b,mod)  
C=pow(2,n,mod)

if n==2:
    print(0)
else:
    print((C-1-A-B)%mod)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(200001)
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)] 
    
def modisisuu(a,n,p):
    bi=str(format(n,"b"))
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res

def do():
    mod=10**9+7
    n,a,b=INTM()
    ct=modisisuu(2,n,mod)
    #print(ct)
    ct=(ct-1-cmb(n,a)-cmb(n,b))%mod
    print(ct)
if __name__ == '__main__':
    do()

Submission status: Runtime Error

Solution code:
import math
import numpy as np
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n, a, b = input().split()
n = int(n)
a = int(a)
b = int(b)
linn = np.linspace(1,n,n)
nn = np.ones(n)*n
nlinn = np.array(list(map(combinations_count, nn, linn)))
nlinn = np.sum(nlinn) - combinations_count(n, a) - combinations_count(n, b)
print(nlinn % (10**9 + 7))

Submission status: Runtime Error

Solution code:
N, a, b = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
X = 2 * (10**5)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, X + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print((pow(2, N) - ax - bx - 1)%mod)

Submission status: Runtime Error

Solution code:
import math
from scipy.special import comb


n, a, b = map(int, input().split())
if n == 2:
    print(0)
else:
    print(((2**n -1) - comb(n, a, exact = True) - comb(n, b, exact = True)) % (10**9 + 7))

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;
int n, a, b;
cin >> n >> a >> b;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}





const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

	int ans;
  	
  	ans = COM(n, a)-COM(n,b)-1-modpow(2, n, 1000000007)
  	cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce

N, A, B = map(int, input().split())

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1

    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))

    return over // under

MAX = 10 ** 9 + 7

acc = 0
used = []
for i in range(1, N+1):
    if i == A:
        continue
    if i == B:
        continue
    if i in used:
        continue

    used.append(i)
    ans = comb(N, i, exact=True)
    acc += ans
    
    used.append(N - i)
    if i in used:
        continue
    
    acc += ans

print(acc % MAX)

Submission status: Runtime Error

Solution code:
import math
n,a,b = map(int, input().split())

S = 0
for i in range(1,n+1):
    fac = 1
    for j in range(n-i+1 , n+1):
        fac = fac * j
    if i != a and i != b:
        S = S + fac / math.factorial(i)
print(int(S % (10**9 + 7)))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(200001)
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)] 
    
def modisisuu(a,n,p):
    bi=str(format(n,"b"))
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res

def do():
    mod=10**9+7
    n,a,b=INTM()
    ct=modisisuu(2,n,mod)
    #print(ct)
    ct=(ct-1-comb(n,a,mod)-comb(n,b,mod))%mod
    print(ct)
if __name__ == '__main__':
    do()

Submission status: Runtime Error

Solution code:
nCr = {}
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,a,b=input().split(' ')
n=int(n)
a=int(a)
b=int(b)
A=1
j=1
A=cmb(n,a)
A=A%1000000007
B=cmb(n,b)
B=B%1000000007
N2=n//1000
N1=n%1000
TTh=860192575
C=1
for i in range(N2):
    C*=TTh
    C=C%1000000007
for i in range(N1):
    C*=2
    C=C%1000000007

C+=1000000007*2
C-=A+B+1
C=C%1000000007
print(C)