TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
 = map(int, input().split())

ans = 1
while(True):
    n = n//k
    if(n == 0):
        break
    ans += 1

print(ans)


n, k = map(int, input().split())

ans = 1
while(True):
    n = n//k
    if(n == 0):
        break
    ans += 1

print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n,k=map(int,input().split())
i=0
while k**i<n:
  i+=1
print i

n,k=map(int,input().split())
i=0
while k**i<=n:
  i+=1
print(i)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N,K=(int(x) for x in input().split())
b=1
a=1
while a=<N:
    b=b+1
    a=K**b
else:
     print(b)

N,K=(int(x) for x in input().split())
b=1
a=1
If N=1:
    print(1)
else:
     while a<=N:
          b=b+1
          a=K**b
     else:
          print(b)



N,K=(int(x) for x in input().split())
k=0
a=K
while a<=N:
    k=+1
    a=K*10**k
print(k)

N,K=(int(x) for x in input().split())
k=0
while a<=x:
    a=K*10**k
    k=+1
print(k)

N,K=(int(x) for x in input().split())
k=0
a=K
while a<=N:
    k=+1
    a=K**k
break
print(k+1)

N,K=(int(x) for x in input().split())
b=1
a=1
if N==1:
    print(1)
else:
     while a<=N:
          b=b+1
          a=K**b
     else:
          print(b)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n, k = map(int, input().split())
ans = 0
while n: 
  ans += 1
  n /= k
print(ans)

n, k = map(int, input().split())
ans = 0
while n: 
  ans += 1
  n //= k
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N,K = map(int, input().split())
cnt = 0
while True:
  cnt += 1
  N = N/K
  if N == 0:
    break
print(cnt)

N,K = map(int, input().split())
cnt = 0
while N >= 1:
  cnt += 1
  N = int(N/K)
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n,k=map(int,input().split())
digit=1
num=k
while n>=k:
  num *= k
  digit += 1

print(digit)
  

import math

n,k=map(int,input().split())

if math.log(n,k) == int(math.log(n,k)):
  res=math.log(n,k) + 1
else:
  res=int(math.log(n,k)) + 2

print(res)

import math
n,k=map(int,input().split())
print(int(math.log(n,k)) + 1)


Verdicts: Time Limit Exceeded

Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq


# input = sys.stdin.readline


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

data = getInputListInt()
n = data[0]
k = data[1]

counter = 0
num = 1

flg = True
while flg:
    counter += 1
    if n > num:
        num *= k
    else:
        flg = False

print(counter)

import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq


# input = sys.stdin.readline


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

data = getInputListInt()
n = data[0]
k = data[1]

counter = 1
num = k

flg = True
while flg:
    if n > num-1:
        num *= k
        counter += 1
    else:
        flg = False

print(counter)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
import sys
N,K = map(int,input().split())
if N < K:
    print(0)
    sys.exit()
count = 1
while N>=K:
    K=K*K
    count += 1

print(count)

N,K = map(int,input().split())
count = 1
while N>=K:
    K=K*K
    count += 1

print(count)

import sys
N,K = map(int,input().split())
K0 = K
if N < K:
    print(1)
    sys.exit()
count = 1
while N>=K:
    K=K*K0
    count += 1

print(count)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
import numpy as np

i = list(map(int, input().split()))
N = i[0]
K = i[1]

N_ = np.base_repr(N, K)

print(N_)
print(len(str(N_)))

import numpy as np

i = list(map(int, input().split()))
N = i[0]
K = i[1]

N_ = np.base_repr(N, K)

print(len(str(N_)))

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N,K=map(int,input().split())
def B(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
print(len(B(N,K)))

N,K=map(int,input().split())
def B(X, n):
    if (int(X/n)):
        return B(int(X/n), n)+str(X%n)
    return str(X%n)
print(len(B(N,K)))

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N, K = [int(_) for _ in input().split()]
for a in range(0, 10**9):
    N = int(N / K)
    if N <= 0:
        print(a)
        break

N, K = [int(_) for _ in input().split()]
for a in range(10**9):
    if K**(a) <= N < K**(a*1):
        print(a+1)
        break

N, K = [int(_) for _ in input().split()]
for a in range(0, 10**9):
    if K**(a) <= N < K**(a*1):
        print(a+1)
        break

N, K = [int(_) for _ in input().split()]
for a in range(10**9):
    if K**(a) <= N < K**(i*1):
        print(a+1)
        break

N, K = [int(_) for _ in input().split()]
for a in range(1, 10**9):
    N = int(N / K)
    if N <= 0:
        print(a)
        break

Verdicts: Wrong Answer

Time Limit Exceeded

Time Limit Exceeded

Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n,k=map(int,input().split())
count=0
while (n/k)>=1:
  n/=k
  count+=1

print(count)

n,k=map(int,input().split())
count=0
while (n/k)>=1:
  n/=k
  count+=1

print(count+1)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N,K=map(int, input().split())
import math
M=int(math.log(N,K)+1)
print(M)
A=''
for i in range(1,M-1,-1):
  print(i)
  A+=str(N//(K**i))
  N-=N%(K**i)
print(A)

N,K=map(int, input().split())

if N<K:
  print(1)

else:
  for i in range(1,N):
    A=K**i
    if N<A*K:
      print(i+1)
      break

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n, k = list(map(int,input().split(" ")))

d=1
while(n>k):
  d+=1
  n= n//k
  
print(d)

n, k = list(map(int,input().split(" ")))

d=0
while(n):
  d+=1
  n= n//k
  
print(d)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
import math


N, K = map(int, input().split())

ans = math.floar(1 + math.log(N)/math.log(K))
print(ans)

import math


N, K = map(int, input().split())

ans = math.floor(1 + math.log(N)/math.log(K))
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
def conv(x, n):
    nchar = '0123456789ABCDEF'
    digit = 0
 
    result = ''
 
    while x > 0:
        result = nchar[x % n] + result
        x = x / n
 
    return result
n, k = map(int, input().split())
print(conv(n, k))

def conv(x, n):
    nchar = '0123456789ABCDEF'
    digit = 0

    result = ''

    while x > 0:
        result = nchar[x % n] + result
        x = x / n

    return result
n, k = map(int, input().split())
print(n, k)

from math import log
n, k = map(int, input().split())
print(int(log(n, k)) + 1)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n,k = [int(x) for x in input().split()]
res = 0
while n > 0:
  n // k
  c += 1
print(res)

n,k = [int(x) for x in input().split()]
res = 0
while n > 0:
  n //= k
  res += 1
print(res)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
import os

def main():
    result_num = []
    a=[int(x) for x in input().split()]
    num,result = a[0],a[1]
    count = 0

    while(True):
        result_num.append(num%result)
        num = num//result
        count += 1
        if result > num:
            result_num.append(num)
            break

    print(count)

if __name__ == "__main__":
    main()

import os

def main():

    N,K = (int(x) for x in input().split())
    count = 0

    while(N > 0):
        N = N // K
        print(N)
        count += 1

    print(count)

if __name__ == "__main__":
    main()

import os

def main():

    N,K = (int(x) for x in input().split())
    count = 0

    while(N > 0):
        
        N = N // K
        count += 1

    print(count)

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N,K=map(int, input().split())


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(Base_10_to_n(N,K))


N,K=map(int, input().split())


def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

print(len(Base_10_to_n(N,K)))


Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n,k=map(int,input().split());print(sum(n>k**i for i in range(100))+k>=n)

n,k=map(int,input().split());print(sum(n>=k**i for i in range(100)))

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n, k = map(int,input().split())

sum = 0
cnt = 0

while True:
    sum += int(k**cnt)
    cnt += 1
    print(sum)
    if sum >= n:
        break
print(cnt)

n, k = map(int,input().split())

sum = 0
cnt = 0

while True:
    sum += int(k**cnt)
    if sum <= n:
        cnt += 1
    else:
        break
print(cnt)

n, k = map(int, input().split())
num = 0
while n != 0:
  n = n // k
  num += 1
 
print(num)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):

import math


x = int(input())


score = int((x // 500 * 1000) + (x % 500 // 5 * 5))


print(score)


import math


n,k = map(int, input().split())


def convert(x,y):
    if int(x/y):
        return convert(int(x/y),y) + str(x%y)
    return str(x%y)


text = len(convert(n,k))


print(text)


Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n, k = map(int, input().split())
i = 1
while k ** i < n:
    i += 1
print(i+1)

n, k = map(int, input().split())
i = 1
while k ** i <= n:
    i += 1
print(i)

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
ans=o
n,k=map(int,input().split())
while n!=0:
  n=n//k
  ans+=1
print(ans)

n,k=map(int,input().split())
ans=0
while n!=0:
  n=n//k
  ans+=1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N, K = map(int, input().split())

ans = 0

while(n_k > 1):
  n_k = N/K
  ans += 1
  
  
print(ans)

N, K = map(int, input().split())

ans = 0

while(N >= 1):
    N= N/K
    ans += 1
  
  
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N, K = map(int, input().split())
ans = 0
while True:
    ans = ans + 1
    N = N / K
    if N < K:
        print(ans + 1)
        return

N, K = map(int, input().split())
ans = 0
while True:
    if N < K:
        print(ans + 1)
        break
    ans = ans + 1
    N = N / K

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
n,k = map(int, input().split())

digits = 0
while n:
  digits += 1
  n//=10
  
print(digits)

n, k = map(int, input().split())

digits = 0
while n:
    digits += 1
    n //= k

print(digits)


Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
import numpy as np
N, K = map(int, input().split())

res = 0
M = N
while M > 1:
    M /= 3
    res += 1
print(res)

import numpy as np
N, K = map(int, input().split())

div = np.log(N) / np.log(3)
print(np.ceil(div).astype(int))

import numpy as np
N, K = map(int, input().split())

res = 0
M = N
while M >= 1:
    M /= K
    res += 1
print(res)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
input_arr = input().split(" ")
n = int(input_arr[0])
k = int(input_arr[1])

ans = ""

num = n
while(num > 0):
    ans += str(num % k)
    num //= k
    print(ans)

print(len(ans))

input_arr = input().split(" ")
n = int(input_arr[0])
k = int(input_arr[1])

ans = ""

num = n
while(num > 0):
    ans += str(num % k)
    num //= k

print(len(ans))

Verdicts: Wrong Answer

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
import math

N = int(input())
X = math.log(N + 1, 2)
Y = math.ceil(X)

print(Y)

import math

N, R = map(int, input().split())
X = math.log(N + 0.000001, R)
Y = math.ceil(X)

print(Y)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
def B():
    n,r = list(map(int, input().split()))
    i = 1
    while True:
        if n < k**i:
            print(i)
            return
        i += 1
B()

def B():
    n,k = list(map(int, input().split()))
    i = 1
    while True:
        if n < k**i:
            print(i)
            return
        i += 1
B()

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N,K=map(int,input().split())
ans=0
while N>0:
    N//M
    ans+=1
print(ans)

N,K=map(int,input().split())
cnt=0
while True:
    N=N//K
    cnt+=1
    if N==0:
        break

print(cnt)

Verdicts: Runtime Error

Accepted
Problem: Given is an integer N. Find the number of digits that N has in base K.

Submission attempts (in order):
N,K = map(int,input().split())

ans = ""

while True:
  r = str(N % K)
  ans += r
  N = N // K
  if N < K:
    ans += str(N % K)
    ans = ans[::-1]
    if ans[0] == "0":
      ans = ans[1:]
      break
  
print(len(ans))

N,K = map(int,input().split())

ans = ""

while True:
  r = str(N % K)
  ans += r
  N = N // K
  if N < K:
    ans += str(N % K)
    break

ans = ans[::-1]
if ans[0] == "0":
  ans = ans[1:]  

print(len(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
s = input()
n, a, b = s.split()
n, a, b =  int(n), int(a), int(b)


a0 = 1
a1 = 1 
for i in range(1, a+1):
  a0 = a0 * (n - i + 1) % 1000000007
  a1 = a1 * i % 1000000007

b0 = 1
b1 = 1 
for i in range(1, b+1):
  b0 = b0 * (n - i + 1) % 1000000007
  b1 = b1 * i % 1000000007

A = (pow(2, n) - 1 - a0 * pow(a1, 1000000005) - b0 * pow(b1, 1000000005)) % 1000000007

def pow(x, n):
    ans = 1
    while n:
        if n % 2:
            ans = ans * x % 1000000007
        x *= x % 1000000007
        n >>= 1
    return ans % 1000000007

print(A)

def pow(x, n):
    ans = 1
    while n:
        if n % 2:
            ans = ans * x % 1000000007
        x *= x % 1000000007
        n >>= 1
    return ans % 1000000007

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


a0 = 1
a1 = 1 
for i in range(1, a+1):
  a0 = a0 * (n - i + 1) % 1000000007
  a1 = a1 * i % 1000000007

b0 = 1
b1 = 1 
for i in range(1, b+1):
  b0 = b0 * (n - i + 1) % 1000000007
  b1 = b1 * i % 1000000007

A = (pow(2, n) - 1 - a0 * pow(a1, 1000000005) - b0 * pow(b1, 1000000005)) % 1000000007

print(A)


Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
mod = 10**9+7

def comb(n, r):
    x = 1
    y = 1
    if n-r<r:
        r = n-r
    for i in range(r):
        x *= n-i
        y *= (i*1)
        x %= mod
        y %= mod
    return x * pow(y, mod-2, mod) % mod

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

print((pow(2, n, mod)-comb(n, a)-comb(n, b)-1)%mod)

mod = 10**9+7

def comb(n, r):
    x = 1
    y = 1
    if n-r<r:
        r = n-r
    for i in range(r):
        x *= n-i
        y *= (i+1)
        x %= mod
        y %= mod
    return x * pow(y, mod-2, mod) % mod

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

print((pow(2, n, mod)-comb(n, a)-comb(n, b)-1)%mod)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    mod = 1000000007

    def modpow(n, k, mod):
        if k == 0:
            return 1
        val = modpow(n, k // 2, mod)
        val = (val * val) % mod
        if k % 2 != 0:
            val *= n
        return val

    def modcmb(n, r, mod):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        over = reduce(lambda v1, v2: v1 * v2 % mod, range(n, n-r, -1))
        under = reduce(lambda v1, v2: v1 * v2 % mod, range(1, r+1))
        return over * modpow(under, mod - 2, mod) % mod

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

    count = modpow(2, n, mod)
    count -= modcmb(n, a, mod)
    count -= modcmb(n, b, mod)

    while count < 0:
        count += mod

    print(count % mod)


main()


#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque
from functools import reduce

#a, b = [int(v) for v in input().split()]


def main():

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

    def pow(n, r):
        if r == 0:
            return 1
        val = pow(n, r // 2)
        val = val * val % mod
        if r % 2 == 1:
            val = val * n % mod
        return val

    def comb(n, r):
        over = 1
        under = 1
        for i in range(r):
            over = over * (n - i) % mod
            under = under * (i + 1) % mod

        return over * pow(under, mod - 2) % mod

    ans = pow(2, n) - 1 - comb(n, a) - comb(n, b) % mod
    while ans < 0:
        ans += mod
    print(ans)


main()


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = 0
MAX = 500000000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def neko(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


if n % 2:
    for i in range((n + 1) // 2):
        ans += neko(n, i) * 2 % mod
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))
else:
    for i in range(n // 2):
        ans += neko(n, i) * 2 % mod
    ans += neko(n, n // 2)
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))


n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = 0
MAX = 500000000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def neko(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


if n % 2:
    for i in range((n + 1) // 2):
        ans += neko(n, i) * 2 % mod
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))
else:
    for i in range(n // 2):
        ans += neko(n, i) * 2 % mod
    ans += neko(n, n // 2)
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))


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


def neko(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


print((pow(2, n, mod) - 1 - neko(n, a) - neko(n, b)) % mod)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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 )
l = []
for r in range(1, n+1):
    if r != a and r != b:
        l.append(cmb(n,r,mod))

print(sum(l))

def cmb(n, r, p):
    r = min(r, n - r)
    upper = 1
    for i in range(n, n - r, -1):
        upper = (upper * i) % p

    lower = 1
    for i in range(1, r + 1):
        lower = (lower * i) % p

    
    return (upper * pow(lower, p - 2, p)) % p

mod = pow(10, 9) + 7
n, a, b = map(int, input().split())
ans = (pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod))%mod
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,a,b = map(int, input().split())
mod = 10**9+7

akai=1
nakai=n
bkai=1
nbkai=n
for i in range(2,a+1):
  akai=(akai%mod)*(i%mod)
  nakai=(nakai%mod)*((n-i+1)%mod)
for i in range(2,b+1):
  bkai=(bkai%mod)*(i%mod)
  nbkai=(nbkai%mod)*((n-i+1)%mod)
akai=akai%mod
bkai=bkai%mod
nakai=nakai%mod
nbkai=nbkai%mod
nakai=nakai*pow(akai,mod-2,mod)
nbkai=nbkai*pow(bkai,mod-2,mod)
print((pow(2,n,mod)-nakai-nbkai)%mod)

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

akai=1
nakai=n
bkai=1
nbkai=n
for i in range(2,a+1):
  akai=(akai%mod)*(i%mod)
  nakai=(nakai%mod)*((n-i+1)%mod)
for i in range(2,b+1):
  bkai=(bkai%mod)*(i%mod)
  nbkai=(nbkai%mod)*((n-i+1)%mod)
akai=akai%mod
bkai=bkai%mod
nakai=nakai%mod
nbkai=nbkai%mod
nakai=nakai*pow(akai,mod-2,mod)
nbkai=nbkai*pow(bkai,mod-2,mod)
print((pow(2,n,mod)-nakai-nbkai-1)%mod)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from math import factorial

M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
c = 1
for i in range(b):
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(factorial(a), M - 2, M)
print(r % M)

M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(f, M - 2, M)
print(r % M)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())
mod = 10**9+7

def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
            result %= mod
    return int(result)

ans = (pow(2, n, mod)-1-(mod-nCr(n, a))-(mod-nCr(n, b)))%mod
print(ans)

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

def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
            result %= mod
    return int(result)

ans = (pow(2, n, mod)-1-(mod-nCr(n, a))-(mod_nCr(n, b)))%mod
print(ans)

n, a, b = map(int, input().split())
mod = 10**9+7
def comb(n, r, mod):
    if r == 0 or r == n:
        return 1
    r = min([r, n-r])
    x, y = 1, 1
    for i in range(1, r+1):
        x *= n+1-i
        x %= mod
        y *= i
        y %= mod
    return x*pow(y, mod-2, mod)%mod

ans = (pow(2, n, mod)+3*mod-1-comb(n, a, mod)-comb(n, b, mod))%mod
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def mpow(a,n,m):
  if n == 0:
    return 1
  elif n == 1:
    return a
  elif n%2==0:
    return (pow(a,n//2,m))**2%m
  else:
    return a*pow(a,n-1,m)%m

n,a,b=map(int,input().split())
mod=1000000007
print((pow(2,n,mod)-1-mpow(n, a, mod)-mpow(n, b, mod))%mod)

import sys 
sys.setrecursionlimit(10**10)

def mod_combination(n, k, mod):
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod

n,a,b=map(int,input().split())
mod=1000000007
print(pow(2,n,mod)-1-mod_combination(n, a, mod)-mod_combination(n, b, mod))

def power(x, a):
    if a == 0:
        return 1
    elif a == 1:
        return x
    elif a % 2 == 0:
        return power(x, a//2) **2 % mod
    else:
        return power(x, a//2) **2 * x % mod

def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  
    denomi = 1  

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod

n,a,b=map(int,input().split())
mod=1000000007
print((pow(2,n,mod)-1-binomial_coefficients(n, a)-binomial_coefficients(n, b))%mod)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split(" "))
from math import factorial
c = n
ans = c
for i in range(1, n + 1):
    c *= (n - i) / (i + 1)
    if i + 1 != a and i + 1 != b:
        ans += c % (10 ** 9 + 7)
if a == 1:
    ans -= n
elif b == 1:
    ans -= n
print(ans)

n, a, b = map(int, input().split(" "))
from math import factorial
c = n
ans = c

for i in range(1, int(n // 2 - 1)):
    c *= (n - i) / (i + 1)
    if i + 1 != a and i + 1 != b:
        ans += c % (10 ** 9 + 7)
ans *= 2
ans += 1
if n % 2 == 0:
    ans += factorial(n) / factorial(n - n / 2) / factorial(n / 2)
ans -= factorial(n) / factorial(n - a) / factorial(a)
ans -= factorial(n) / factorial(n - b) / factorial(b)
print(ans)

from math import factorial
n, a, b = map(int, input().split(" "))
mod = pow(10, 9) + 7
ans = pow(2, n, mod)
ans = (ans - 1) % mod

def reduce(ans, r):
    c = n % mod
    for i in range(1, r):
        c *= ((n - i) % mod) * pow(i + 1, mod - 2, mod)
        c %= mod
    ans -= c
    if ans < 0:
        ans += mod
    return ans % mod
    
ans = reduce(ans, a)
ans = reduce(ans, b)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def f(A):
    bunsi = reduce(lambda x, y: x*y%mod, range(N, N-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod
  
ans = pow(2, n, mod) - f(a) -f(b) - 1
ans %= mod
print(ans)

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


f = 1
for i in range(1, n+1):
    f *= i
    f %= mod

inv = pow(f, mod-2, mod)
for i in range(1, n+1):
    if i != a or i != b:
        ans += inv*i%mod
print(ans)

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

def comb(N, A, MOD):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD

print((pow(2, n, mod) - 1 - comb(n, a, mod) - comb(n, b, mod))%mod)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math

n, a, b = list(map(int, input().split()))
MAX = 510000
MOD = 1000000007

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
com = [0 for i in range(MAX)]

print(fac[1])

def cominit() :
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  com[1] = n
  for i in range(2, MAX) :
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
    com[i] = com[i-1] * (n-(i-1)) * inv[i] % MOD
    
  return fac, finv, inv, com
 
"""
def combination(n, r, inv) :
  ans = 1
  if(n < r) : 
    return 0
  if((n < 0) or (r < 0)) :
    return 0
  for i in range(0, r) :
    return (fac[n] * (finv[r] * finv[n-r] % MOD) % MOD) 
 """

def two_n_mod(n) :
  ans = 1
  while(n > 32) :
    ans = ans * 2**32 % MOD
    n -= 32
  return ans * 2**n % MOD

temp = cominit()
##print(two_n_mod(1000000000))
print((two_n_mod(n) - 1 - com[a] - com[b]) % MOD)



n, a, b = list(map(int, input().split()))
MAX = 510000
MOD = 1000000007


fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
com = [0 for i in range(MAX)]
power = [2 for i in range(32)]

for i in range(1, 32) :
  power[i] = power[i-1] * power[i-1] % MOD

def cominit() :
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  com[1] = n
  for i in range(2, MAX) :
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
    com[i] = com[i-1] * (n-(i-1)) * inv[i] % MOD
    
  return fac, finv, inv, com


def two_n_mod(n) :
  ans = 1
  temp_i = 0
  temp = [0 for i in range(32)]
    
  for i in range(32) :
    temp[i] += n%2
    n = int(n/2)
  ans = (2**n) % MOD
  for i in range(32) :
    ans = ans * (power[i] ** temp[i]) % MOD
  return ans

temp = cominit()
##print(two_n_mod(1000000000))
##print(2**n % MOD)
print((two_n_mod(n) - 1 - com[a] - com[b]) % MOD)



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a=pow(2,10**7,10**9+7)
print(a)

import math
numbers =input().rstrip().split(" ")
N =int(numbers[0])
a =int(numbers[1])
b =int(numbers[2])
Ya=math.factorial(a)
Yb=math.factorial(b)
Xa=1
Xb=1
for i in range(a):
    Xa=Xa*(N-i)
for i in range(b):
    Xb=Xb*(N-i)

d=1000000007
#answer is 2**N-nca-ncb-1 mod d
A=pow(2,N)
B=Xa*pow(Ya,d-2)
C=Xb*pow(Yb,d-2)
answer=(A+B+C-1)%d
print(answer)

a=pow(2,10**7)
print(a)


def cmod(n, r, p):
    x,y  = 1, 1
    for i in range(r):
        x = x * (n - i) % p
        y = y * (r - i) % p
    return (x * pow(y, p - 2, p)) % p


n, a, b = map(int, (input().split()))
p = 10 ** 9 + 7
print((pow(2, n, p) - 1 - cmod(n, a, p) - cmod(n, b, p)) % p)


Verdicts: Wrong Answer

Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
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(ans-n1-n2)

n,a,b=map(int,input().split())
ans=2**n
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(ans-n1-n2)

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))

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

def comb(n,r):
    P=1
    R=1
    for i in range(r):
        P=P*(n-i)%mod
        R=R*(r-i)%mod
    return P*pow(R,mod-2,mod)%mod

combN=pow(2,n,mod)-1
print((combN-comb(n,a)-comb(n,b))%mod)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())
def cmb(n, r, p):
    ans = 1
    for i in range(1, r + 1):
        ans *= 
        ans /= i
        ans %= mod
    return int(ans)
 p = 10 ** 9 + 7
N = 10 ** 6  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
import math
mod = 10 ** 9 + 7
res = pow(2, n, mod) - 1 - mod_comb(n, a, mod) - mod_comb(n, b, mod)
print(res % mod)

n, a, b = map(int, input().split())
def mod_comb(n, r, mod):
    ans = 1
    for i in range(1, r + 1):
        ans *= n - (i - 1)
        ans %= mod
        ans *= inv[i]
        ans %= mod
    return int(ans)
 p = 10 ** 9 + 7
N = 10 ** 6  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
import math
mod = 10 ** 9 + 7
res = pow(2, n, mod) - 1 - mod_comb(n, a, mod) - mod_comb(n, b, mod)
print(res % mod)


n, a, b = map(int, input().split())
def mod_comb(n, r, mod):
    ans = 1
    for i in range(1, r + 1):
        ans *= n - (i - 1)
        ans %= mod
        ans *= inv[i]
        ans %= mod
    return int(ans)
p = 10 ** 9 + 7
N = 10 ** 6  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
import math
mod = 10 ** 9 + 7
res = pow(2, n, mod) - 1 - mod_comb(n, a, mod) - mod_comb(n, b, mod)
print(res % mod)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

up=1
down=1
for i in range(1,b+1):
	up*=(n-i+1)
	up%mod
	down*=i
	if i==a:
		upa=up
		downa=down

nca=upa%mod
nca*=pow(downa,mod-2,mod)
nca%=mod
ncb=(up%mod)
ncb=*pow(down,mod-2,mod)
ncb%=mod
print((res-nca-ncb)%mod)

mod=10**9+7

n,a,b=map(int,input().split())
res=pow(2,n,mod)
res=(res-1)%mod

ncb=1
for i in range(1,b+1):
	ncb*=(n-i+1)*pow(i,mod-2,mod)
	ncb%=mod
	if i==a:
		nca=ncb
		
print((res-nca-ncb)%mod)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod) :
    ans1 = 1
    ans2 = 1
    for i in range(r) :
        ans1 *= n-i
        ans2 *= i+1
    return ans1 * pow(ans2, mod-2, mod)

print(pow(2, n, mod) - comb(n, a, mod) - comb(n, b, mod) - 1)

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

def comb(n, r, mod) :
    ans1 = 1
    ans2 = 1
    for i in range(r) :
        ans1 = (ans1 * (n-i)) % mod
        ans2 = (ans2 * (i+1)) % mod
    return ans1 * pow(ans2, mod-2, mod)

ans = pow(2, n, mod) - comb(n, a, mod) - comb(n, b, mod) - 1
print(ans%mod)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from scipy.misc import comb
n, a, b = map(int, input().split())
sum = 0
for i in range(1, n+1):
  if i in (a, b):
    continue
  else:
    sum += comb(n, i)
print(int(sum))

def comb(n, k, mod):
  r = min(k, n-k)
  p = q = 1
  for i in range(r):
    p = p*(n-i)%mod
    q = q*(i+1)%mod
  return p*pow(q, mod-2, mod) % mod

n, a, b = map(int, input().split())
mod = (10**9+7)
ans = (pow(2, n, mod)-comb(n, a, mod)-comb(n, b, mod)-1)%mod
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#TLE

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


na = list(bin(n))
nb = na[3:]

ans = 2

for b in nb:
    if b == '0':
        ans **= 2
    else:
        ans = (ans ** 2) * 2

if n == 0:
    ans = 1


def comb(n, r):
    m = 1
    for i in range(n-r+1, n+1):
        m *= i
    for i in range(1, r+1):
        m //= i
    return m
ans -= comb(n, a) + comb(n, b) + 1

print(int(ans % (1000000007)))

#TLE

#comb_mod(n, r, mod) = nCr % mod
def comb_mod(n, r, mod):
    ans = 1
    if r <= n/2:
        for i in range(n-r+1, n+1):
            ans *= i
            ans %= mod
        for i in range(1, r+1):
            ans *= pow(i, mod-2, mod)
            ans %= mod
    else:
        for i in range(r+1, n+1):
            ans *= i
            ans %= mod
        for i in range(1, n-r+1):
            ans *= pow(i, mod-2, mod)
            ans %= mod
    return ans

n, a, b = map(int, input().split())
ans = pow(2, n, 10**9+7) - comb_mod(n, a, 10**9+7) - comb_mod(n, b, 10**9+7) - 1
if ans < 0:
    ans += 10**9 + 7
if ans < 0:
    ans += 10**9 + 7

print(int(ans))

Verdicts: Runtime Error

Accepted