ZhenlongDai/ACPR huggingface dataset:
Problem: p03050
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import math
N=int(input())
n=int(math.sqrt(N))
plist=[]
for i in range(1,n+1):
    if N%i == 0:
        plist.append(i)
        if i != int(N/i):
            plist.append(int(N/i))
ans=0
for x in plist:
    if x<int(N/2):
        kari=int(N/x)-1
        ans+=kari
print(ans)
            


Failing test case input:
1110011010101

Expected output:
1268606180668


Actual output:
1268606638456


Fixed submission (verdict: Accepted):


import math
N=int(input())
n=int(math.sqrt(N))
plist=[]
for i in range(1,n+1):
    if N%i == 0:
        plist.append(i)
        if i != int(N/i):
            plist.append(int(N/i))
ans=0
for i in range(len(plist)):
    x=plist[i]
    kari=int(N/x)-1
    if kari == 0:
        pass
    else:
        q=int(N/kari)
        r=N%kari
        if q == r:
            ans+=kari
print(ans)

Problem: p03050
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
c = 0
for i in range(1, int(n**0.5)+1):
    if n % i == 0 and n / i >= i:
        c += int(n / i) - 1
print(c)

Failing test case input:
1000000000000

Expected output:
2499686339916

Actual output:
2499687339915


Fixed submission (verdict: Accepted):
n = int(input())
cnt = 0
for i in range(1, int(n**0.5)+1):
    if n % i == 0 and n / i - 1 > i:
        cnt += int(n / i) - 1
print(cnt)

Problem: p03050
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
n = int(input())
cnt = 0

for i in range(1,int(math.sqrt(n)) + 1):
    if (n-i) % i == 0:
        cnt += (n-i) 

print(cnt)

Failing test case input:
1001111010111

Expected output:
1528108711160


Actual output:
24026662136888


Fixed submission (verdict: Accepted):
import math
n = int(input())
cnt = 0

for i in range(1,int(math.sqrt(n)) + 1):
    if n % i == 0:
        if (n-i) 
            cnt += (n-i) 
print(cnt)

Problem: p03050
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
N = int(input())
result = 0

root = math.ceil(math.sqrt(N) - 1)
for i in range(root):
    if N % (i + 1) == 0:
        result += N 

print(result)

Failing test case input:
1000111010101

Expected output:
1143109738524


Actual output:
4000444040404


Fixed submission (verdict: Accepted):
import math
N = int(input())
result = 0

root = math.ceil(math.sqrt(N))
for i in range(root):
    if N % (i + 1) == 0 and (i + 1) + 1 < N 
        result += N 

print(result)

Problem: p03050
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
N = int(input())

ans = 0
for i in range(1, math.ceil(N**(1/2))):
    if N % i == 0:
        ans += N

print(ans)


Failing test case input:
1110110001101

Expected output:
1110110001100


Actual output:
1110110001101


Fixed submission (verdict: Accepted):
import math
N = int(input())

ans = 0
for i in range(1, math.ceil(N**(1/2))):
    if N % i == 0:
        if N % (N
            ans += N

print(ans)
Problem: p03050
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys


def solve(N: int):
    ret = 0
    i = 1
    used = set()
    while i * i <= N:
        tmp = N - i
        if tmp % i == 0:
            val = tmp 
            if not val in used:
                ret += val
                used.add(val)
        if N % (i + 1):
            val2 = N 
            
            if not val2 in used:
                ret += val2
                used.add(val2)
        i += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()


Failing test case input:
1000000000000

Expected output:
2499686339916

Actual output:
85999991517829


Fixed submission (verdict: Accepted):

import sys


def solve(N: int):
    ret = 0
    i = 1
    used = set()
    while (i - 1) ** 2 <= N:
        
        tmp = N - i
        if tmp % i == 0:
            val = tmp 
            if val > 0 and N 
                ret += val
                used.add(val)
        if N % (i + 1):
            val = N 
            if val > 0 and N 
                ret += val
                used.add(val)
        i += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Problem: p03050
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())

ans = 0
for div in range(1, int(n**0.5) +1 ):
    if (n - div)%div==0:
        ans += (n-div)
    
print(ans)

Failing test case input:
1000011010101

Expected output:
1335678223520


Actual output:
8000087395408


Fixed submission (verdict: Accepted):
n = int(input())

ans = 0
for div in range(1, int(n ** 0.5) + 1):
    if (n - div) % div == 0 and div < (n - div) 
        ans += (n - div) 

print(ans)
Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial
N=int(input())
K=int(input())
S = list(map(int,str(N)))
ans = 0
l = len(S)

def C(n,r):
    if n >= r:
        return factorial(n) 
    else:
        return 0

def D(i,j): 
    return (9**j)*C(i,j)

for i in range(l):
    if K >= 1:
        ans = ans + (int(S[i])-1)*D(l-1,K-1) + D(l-1,K)
        K -= 1
        l -= 1
    else:
        break

if K <= l:
    ans += 1

print(ans)


Failing test case input:
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
1

Expected output:
900


Actual output:
15865456625470505955888870605565339083421714604944875649660803862186991998849085653520048875946608108663128646540628038902701485855866880000000000000000000001


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
K = int(input())
S = list(map(int,str(N))) 
ans = 0
digit = len(S)
k = K

def D(i,j): 
    if i >= j:
        return (9**j) * (factorial(i) 
    else:
        return 0

if K > len(S):
    print(0)
    exit()

for i in range(digit):
    digit -= 1
    if int(S[i]) == 0:
        if K == len(S):
            print(0)
            exit()
        continue
    ans += D(digit,k)
    k -= 1
    if k == 0:
        ans += S[i]
        break
    ans += (int(S[i]-1))*D(digit,k)
print(ans)

Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial
N=int(input())
K=int(input())

S = list(map(int,str(N)))
ans = 0
l = len(S)

def C(n,r):
    if n >= r:
        return factorial(n) 
    else:
        return 0

def D(i,j): 
    return (9**j)*C(i,j)

for i in range(l):
    if K >= 1:
        ans = ans + (int(S[i])-1)*D(l-1,K-1) + D(l-1,K)
        K -= 1
        l -= 1
    else:
        break

if ans != 0:
    ans += 1

print(ans)

Failing test case input:
314159
1

Expected output:
48


Actual output:
1321


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
K = int(input())
S = list(map(int,str(N))) 
ans = 0
digit = len(S)
k = K

def D(i,j): 
    if i >= j:
        return (9**j) * (factorial(i) 
    else:
        return 0

if K > len(S):
    print(0)
    exit()

for i in range(digit):
    digit -= 1
    if int(S[i]) == 0:
        if K == len(S):
            print(0)
            exit()
        continue
    ans += D(digit,k)
    k -= 1
    if k == 0:
        ans += S[i]
        break
    ans += (int(S[i]-1))*D(digit,k)
print(ans)
Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()
K = int(input())

DP = [[[0 for i in range(K+1)] for i in range(2)] for i in range(len(N))]

for d in range(int(N[0])+1):
    DP[0][d<int(N[0])][d!=0] += 1

for i in range(len(N)-1):
    for j in range(2):
        for k in range(K+1):
            for d in range(10 if j else int(N[i+1])+1):
                if k+(d!=0) <= K:
                    DP[i+1][j|(d<int(N[i]))][k+(d!=0)] += DP[i][j][k]

print(DP[len(N)-1][0][K]+DP[len(N)-1][1][K])

Failing test case input:
314159
3

Expected output:
9427


Actual output:
9432


Fixed submission (verdict: Accepted):
N = input()
K = int(input())

DP = [[[0 for i in range(K+1)] for i in range(2)] for i in range(len(N))]

for d in range(int(N[0])+1):
    DP[0][d<int(N[0])][d!=0] += 1

for i in range(len(N)-1):
    for j in range(2):
        for k in range(K+1):
            for d in range(10 if j else int(N[i+1])+1):
                if k+(d!=0) <= K:
                    DP[i+1][j|(d<int(N[i+1]))][k+(d!=0)] += DP[i][j][k]

print(DP[len(N)-1][0][K]+DP[len(N)-1][1][K])

Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from math import factorial
N=int(input())
K=int(input())
S = list(map(int,str(N))) 
ans = 0
k = K
l = len(S) 

def C(n,r): 
    if n >= r:
        return factorial(n) 
    else:
        return 0

def D(i,j): 
    return (9**j)*C(i,j)

if K > len(S):
    print(0)
    exit()

for i in range(l):
    if k >= 1:
        ans = ans + (int(S[i])-1)*D(l-1,k-1) + D(l-1,k)
        k -= 1
        l -= 1
    else:
        break

ans += 1
print(ans)

Failing test case input:
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
1

Expected output:
900


Actual output:
15865456625470505955888870605565339083421714604944875649660803862186991998849085653520048875946608108663128646540628038902701485855866880000000000000000000001


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
K = int(input())
S = list(map(int,str(N))) 
ans = 0
digit = len(S)
k = K

def D(i,j): 
    if i >= j:
        return (9**j) * (factorial(i) 
    else:
        return 0

if K > len(S):
    print(0)
    exit()

for i in range(digit):
    digit -= 1
    if int(S[i]) == 0:
        if K == len(S):
            print(0)
            exit()
        continue
    ans += D(digit,k)
    k -= 1
    if k == 0:
        ans += S[i]
        break
    ans += (int(S[i]-1))*D(digit,k)
print(ans)
Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N=int(input())
K=int(input())

n=(str(N))
dp=[[0]*(K+1) for i in range(len(n))]
dp[0][0]=1
dp[0][1]=int(n[0])


for i in range(len(n)-1):
    dp[i+1][0]+=dp[i][0]
    dp[i+1][1]+=(dp[i][0])*9
    for j in range(1,K):
        dp[i+1][j]+=dp[i][j]
        dp[i+1][j+1]+=(dp[i][j]-1)*9+int(n[i+1]) if i==0 else dp[i][j]*9
    dp[i+1][K]+=dp[i][K]
    
print(dp[-1][-1])



Failing test case input:
100
84

Expected output:
0


Actual output:
-90


Fixed submission (verdict: Accepted):


N=int(input())
K=int(input())

n=(str(N))
dp=[[0]*(K+1) for i in range(len(n))]
dp[0][0]=1
dp[0][1]=int(n[0])


count=1
for i in range(len(n)-1):
    dp[i+1][0]+=dp[i][0]
    dp[i+1][1]+=(dp[i][0])*9
    
    for j in range(1,K):
        dp[i+1][j]+=dp[i][j]
        dp[i+1][j+1]+=max((dp[i][j]-1)*9+int(n[i+1]),0) if j==count else dp[i][j]*9
    if int(n[i+1])!=0:
        count+=1
    dp[i+1][K]+=dp[i][K]
    
print(dp[-1][-1])

Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial as fac

def comb(n,r):
    if ( r<0 or r>n ):
        return 0
    return fac(n)/(fac(r)*fac(n-r))


n=int(input())
k=int(input())

nn=str(n)
keta=len(nn)

ans=0

if keta<k:
    print(0)
    exit()

zero=0

for i in range(keta):
    if int(nn[i])==0:zero+=1
    ans+=comb(keta-i-1,k-i+zero)*9**(k-i)
    if int(nn[i])-1>=0:
        ans+=(int(nn[i])-1)*comb(keta-i-1,k-i-1+zero)*9**(k-i-1+zero)

if keta-zero==k:ans+=1

print(int(ans))


Failing test case input:
100
001

Expected output:
19


Actual output:
20


Fixed submission (verdict: Accepted):
from math import factorial as fac

def comb(n,r):
    if ( r<0 or r>n ):
        return 0
    return fac(n)/(fac(r)*fac(n-r))


n=int(input())
k=int(input())

nn=str(n)
keta=len(nn)

ans=0

if keta<k:
    print(0)
    exit()

zero=0









def search(n,k):
    if k<=0:return
    global ans
    nn = str(n)
    keta = len(nn)
    ans += comb(keta - 1, k ) * 9 ** k
    if int(nn[0])-1>0:
        ans+=(int(nn[0])-1)*comb(keta-1,k-1)*9**(k-1)
    ne=n-int(nn[0])*10**(keta-1)
    search(ne,k-1)


search(n,k)
for i in range(keta):
    if nn[i]=="0":zero+=1
if keta-zero>=k:ans+=1
print(int(ans))
Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = list(map(int,list(input())))
k = int(input())
l = len(n)
count = 0 
lst = [[0]*(k+1) for _ in range(l+1)] 
for i in range(l):
    if count < k:
        lst[i+1][count] += 1
        lst[i+1][count+1] += n[i]-1
    if count == k:
        lst[i+1][count] += 1
    for j in range(k):
        lst[i+1][j] += lst[i][j]
        lst[i+1][j+1] += 9*lst[i][j]
    lst[i+1][k] += lst[i][k]
    if n[i] != 0:
        count += 1
if count == k:
    print(lst[l][k]+1)
else:
    print(lst[l][k])

Failing test case input:
100
001

Expected output:
19


Actual output:
21


Fixed submission (verdict: Accepted):
n = list(map(int,list(input())))
k = int(input())
l = len(n)
count = 0 
lst = [[0]*(k+1) for _ in range(l+1)] 
for i in range(l):
    if count < k:
        if n[i] != 0:
            lst[i+1][count] += 1
            lst[i+1][count+1] += n[i]-1
    if count == k:
        if n[i] != 0:
            lst[i+1][count] += 1
    for j in range(k):
        lst[i+1][j] += lst[i][j]
        lst[i+1][j+1] += 9*lst[i][j]
    lst[i+1][k] += lst[i][k]
    if n[i] != 0:
        count += 1
if count == k:
    print(lst[l][k]+1)
else:
    print(lst[l][k])

Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial
N=int(input())
K=int(input())
S = list(map(int,str(N))) 
ans = 0
k = K
l = len(S) 

def C(n,r): 
    if n >= r:
        return factorial(n) 
    else:
        return 0

def D(i,j): 
    return (9**j)*C(i,j)

if K > len(S):
    print(0)
    exit()

for i in range(l):
    if k >= 1 and int(S[i])!=0:
        ans = ans + (int(S[i])-1)*D(l-1,k-1) + D(l-1,k)
        k -= 1
        l -= 1
    elif k >= 1 and int(S[i])==0:
        l -= 1
    else:  
        break

ans += 1
print(ans)

Failing test case input:
314159
3

Expected output:
9427


Actual output:
108937


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
K = int(input())
S = list(map(int,str(N))) 
ans = 0
digit = len(S)
k = K

def D(i,j): 
    if i >= j:
        return (9**j) * (factorial(i) 
    else:
        return 0

if K > len(S):
    print(0)
    exit()

for i in range(digit):
    digit -= 1
    if int(S[i]) == 0:
        if K == len(S):
            print(0)
            exit()
        continue
    ans += D(digit,k)
    k -= 1
    if k == 0:
        ans += S[i]
        break
    ans += (int(S[i]-1))*D(digit,k)
print(ans)
Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial
N=int(input())
K=int(input())

S = list(map(int,str(N)))
ans = 0
l = len(S)

def C(n,r):
    if n >= r:
        return factorial(n) 
    else:
        return 0

def D(i,j): 
    return (9**j)*C(i,j)

for i in range(l):
    if K >= 1:
        ans = ans + (int(S[i])-1)*D(l-1,K-1) + D(l-1,K)
        K -= 1
        l -= 1
    else:
        ans += 1
        break

if ans != 0:
    ans += 1

print(ans)

Failing test case input:
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
2

Expected output:
400950


Actual output:
142949366766865568814675480607720024872850196238493223025226636818896938009832165686261450478226004373005159118325658693951613387711447040000000000000000000002


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
K = int(input())
S = list(map(int,str(N))) 
ans = 0
digit = len(S)
k = K

def D(i,j): 
    if i >= j:
        return (9**j) * (factorial(i) 
    else:
        return 0

if K > len(S):
    print(0)
    exit()

for i in range(digit):
    digit -= 1
    if int(S[i]) == 0:
        if K == len(S):
            print(0)
            exit()
        continue
    ans += D(digit,k)
    k -= 1
    if k == 0:
        ans += S[i]
        break
    ans += (int(S[i]-1))*D(digit,k)
print(ans)

Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial
N=int(input())
K=int(input())

S = list(map(int,str(N)))
ans = 0
k = K
l = len(S)

def C(n,r):
    if n >= r:
        return factorial(n) 
    else:
        return 0

def D(i,j): 
    return (9**j)*C(i,j)

for i in range(l):
    if k >= 1:
        
        
        
        ans = ans + (int(S[i])-1)*D(l-1,k-1) + D(l-1,k)
        k -= 1
        l -= 1
    else:
        
        break


if K <= len(S):
    ans += 1

print(ans)



Failing test case input:
314159
1

Expected output:
48


Actual output:
1321


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
K = int(input())
S = list(map(int,str(N))) 
ans = 0
digit = len(S)
k = K

def D(i,j): 
    if i >= j:
        return (9**j) * (factorial(i) 
    else:
        return 0

if K > len(S):
    print(0)
    exit()

for i in range(digit):
    digit -= 1
    if int(S[i]) == 0:
        if K == len(S):
            print(0)
            exit()
        continue
    ans += D(digit,k)
    k -= 1
    if k == 0:
        ans += S[i]
        break
    ans += (int(S[i]-1))*D(digit,k)
print(ans)
Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial
N=int(input())
K=int(input())
S = list(map(int,str(N)))
ans = 0
l = len(S)

def C(n,r):
    if n >= r:
        return factorial(n) 
    else:
        return 0

def D(i,j): 
    return (9**j)*C(i,j)

for i in range(l):
    if K >= 1:
        ans = ans + (int(S[i])-1)*D(l-1,K-1) + D(l-1,K)
        K -= 1
        l -= 1
    else:
        break

if K <= len(S):
    ans += 1

print(ans)


Failing test case input:
314159
3

Expected output:
9427


Actual output:
108937


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
K = int(input())
S = list(map(int,str(N))) 
ans = 0
digit = len(S)
k = K

def D(i,j): 
    if i >= j:
        return (9**j) * (factorial(i) 
    else:
        return 0

if K > len(S):
    print(0)
    exit()

for i in range(digit):
    digit -= 1
    if int(S[i]) == 0:
        if K == len(S):
            print(0)
            exit()
        continue
    ans += D(digit,k)
    k -= 1
    if k == 0:
        ans += S[i]
        break
    ans += (int(S[i]-1))*D(digit,k)
print(ans)

Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N=int(input())
K=int(input())

n=(str(N))
dp=[[0]*(K+1) for i in range(len(n))]
dp[0][0]=1
dp[0][1]=int(n[0])


for i in range(len(n)-1):
    dp[i+1][0]+=dp[i][0]
    dp[i+1][1]+=(dp[i][0])*9
    for j in range(1,K):
        dp[i+1][j]+=dp[i][j]
        dp[i+1][j+1]+=(dp[i][j]-1)*9+int(n[i+1]) if dp[i][j+1]==0 else dp[i][j]*9
    dp[i+1][K]+=dp[i][K]
    
print(dp[-1][-1])


Failing test case input:
100
28

Expected output:
0


Actual output:
-90


Fixed submission (verdict: Accepted):


N=int(input())
K=int(input())

n=(str(N))
dp=[[0]*(K+1) for i in range(len(n))]
dp[0][0]=1
dp[0][1]=int(n[0])


count=1
for i in range(len(n)-1):
    dp[i+1][0]+=dp[i][0]
    dp[i+1][1]+=(dp[i][0])*9
    
    for j in range(1,K):
        dp[i+1][j]+=dp[i][j]
        dp[i+1][j+1]+=max((dp[i][j]-1)*9+int(n[i+1]),0) if j==count else dp[i][j]*9
    if int(n[i+1])!=0:
        count+=1
    dp[i+1][K]+=dp[i][K]
    
print(dp[-1][-1])

Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=input()
k=int(input())
ln=len(N)
DP=[[[0]*2 for _ in range(k+1)] for _ in range(len(N)+1)]
DP[0][0][0]=1
for i in range(1,len(N)+1):
  DP[i][0][1]=1
for i in range(len(N)):
  ni=int(N[i])
  for j in range(1,k+1):
    DP[i+1][j][1]=DP[i][j][1]+max(0,ni-1)*DP[i][j-1][0]+9*DP[i][j-1][1]+DP[i][j][0]
    if ni==0:
      DP[i+1][j][0]=DP[i][j][0]
    else:
      DP[i+1][j][0]=DP[i][j-1][0]
print(DP[ln][k][0]+DP[ln][k][1])



Failing test case input:
100
001

Expected output:
19


Actual output:
21


Fixed submission (verdict: Accepted):
N=input()
k=int(input())
ln=len(N)
DP=[[[0]*2 for _ in range(k+1)] for _ in range(len(N)+1)]
DP[0][0][0]=1
for i in range(1,len(N)+1):
  DP[i][0][1]=1
for i in range(len(N)):
  ni=int(N[i])
  for j in range(1,k+1):
    DP[i+1][j][1]=DP[i][j][1]+max(0,ni-1)*DP[i][j-1][0]+9*DP[i][j-1][1]
    if ni==0:
      DP[i+1][j][0]=DP[i][j][0]
    else:
      DP[i+1][j][0]=DP[i][j-1][0]
      DP[i+1][j][1]+=DP[i][j][0]
print(DP[ln][k][0]+DP[ln][k][1])
Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial
N=int(input())
K=int(input())

S = list(map(int,str(N)))
ans = 0
l = len(S)

def C(n,r):
    if n>r:
        return factorial(n) 
    else:
        return 0

def D(i,j): 
    return (9**j)*C(i,j)

for i in range(l):
    if K >= 1:
        ans = ans + (int(S[i])-1)*D(l-1,K-1) + D(l-1,K)
        K -= 1
        l -= 1
    else:
        ans += 1
        break
print(ans)


Failing test case input:
25
1

Expected output:
11


Actual output:
2


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
K = int(input())
S = list(map(int,str(N))) 
ans = 0
digit = len(S)
k = K

def D(i,j): 
    if i >= j:
        return (9**j) * (factorial(i) 
    else:
        return 0

if K > len(S):
    print(0)
    exit()

for i in range(digit):
    digit -= 1
    if int(S[i]) == 0:
        if K == len(S):
            print(0)
            exit()
        continue
    ans += D(digit,k)
    k -= 1
    if k == 0:
        ans += S[i]
        break
    ans += (int(S[i]-1))*D(digit,k)
print(ans)

Problem: p02781
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = input()
n = int(N)
l = len(N)
k = int(input())
ans = 0
tmp = 0
def c(x,y):
  z = 1
  for w in range(y):
    z *= x - w
    z /= y - w
  return z

for i in range(l):
  for d in range(10):
    if d < int(N[i]):
      if d == 0:
        now = c(l-1-i,k-tmp) * 9**(k-tmp)
        ans += now
        
      elif k - tmp - 1 >= 0:
        now =  c(l-1-i,k-tmp-1) * 9**(k-tmp-1)
        ans += now
        
    elif d == int(N[i]):
      tmp += 1
  if tmp == k:
    ans += 1
    print(int(ans))
    break

Failing test case input:
314159
16

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
N = input()
n = int(N)
l = len(N)
k = int(input())
ans = 0
tmp = 0
def c(x,y):
  z = 1
  for w in range(y):
    z *= x - w
    z /= y - w
  return z

for i in range(l):
  for d in range(10):
    if d < int(N[i]):
      if d == 0 and k - tmp >= 0:
        now = c(l-1-i,k-tmp) * 9**(k-tmp)
        ans += now
        
      elif k - tmp - 1 >= 0:
        now =  c(l-1-i,k-tmp-1) * 9**(k-tmp-1)
        ans += now
        
    elif d == int(N[i]):
      if d != 0:
        tmp += 1
if k == tmp:
  ans += 1
print(int(ans))
Problem: p04048
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N, X = list(map(int, input().split()))

ans = N
N, X = X, N - X
while N and X:
  if X > N:
    d, m = divmod(X, N)
    ans += d * 2 * N
    N, X = N, m
  else:
    d, m = divmod(N, X)
    ans += (d * 2 - 1) * X + m * 2
    N, X = m, X - m

print(ans)

Failing test case input:
150 6

Expected output:
432


Actual output:
438


Fixed submission (verdict: Accepted):
N, X = list(map(int, input().split()))

ans = N
N, X = X, N - X
while N and X:
  if X > N:
    d, m = divmod(X, N)
    if m == 0:
      ans += (d * 2 - 1) * N
    else:
      ans += d * 2 * N
    N, X = N, m
  else:
    d, m = divmod(N, X)
    if m == 0:
      ans += (d * 2 - 1) * X
    else:
      ans += d * 2 * X + m * 2
    N, X = m, X - m

print(ans)

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

n, x = map(int, input().split())
print(3*gcd(n, x))

Failing test case input:
172 1

Expected output:
513


Actual output:
3


Fixed submission (verdict: Accepted):
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

n, x = map(int, input().split())
print(3*(n - gcd(n, x)))

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def is_prime(n: int)->bool:
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return True


def mysterious_light(N: int, X: int)->int:
    if is_prime(N):
        return 3*(N-1)
    return 3*max(N-X, X)


if __name__ == "__main__":
    N, X = map(int, input().split())

    ans = mysterious_light(N, X)
    print(ans)


Failing test case input:
129 2

Expected output:
384


Actual output:
381


Fixed submission (verdict: Accepted):
def gcd(a: int, b: int)->int:
    if a < b:
        a, b = b, a
    return a if b == 0 else gcd(b, a % b)


def mysterious_light(N: int, X: int)->int:
    g = gcd(N, X)
    return 3 * max(N-g, g)


if __name__ == "__main__":
    N, X = map(int, input().split())

    ans = mysterious_light(N, X)
    print(ans)

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from math import floor
N, X = [int(x) for x in input().split()]

y = N-X
x = X
L = X
while x > 0:

	k, z = divmod(y, x)
	dL = x*(2*k-1)+y
	L += x*(2*k-1)+y
	print(x, y, k, dL)
	y, x = (x, z)


print(L)

Failing test case input:
772 4

Expected output:
2304


Actual output:
4 768 192 2300
2304


Fixed submission (verdict: Accepted):

from math import floor
N, X = [int(x) for x in input().split()]

y = N-X
x = X
L = X
while x > 0:

	k, z = divmod(y, x)

	L += x*(2*k-1)+y

	y, x = (x, z)


print(L)
Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x = map(int,input().split())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

k = gcd(n,x)
if k == 1:
    print((n-1)*3)
else:
    print((int(n/k)-1)*3)


Failing test case input:
702 4

Expected output:
2100


Actual output:
1050


Fixed submission (verdict: Accepted):
n,x = map(int,input().split())

def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

k = gcd(n,x)
if k == 1:
    print((n-1)*3)
else:
    print((int(n/k)-1)*3*k)

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def is_prime(n: int)->bool:
    d = 2
    while d * d <= n:
        if n % d == 0:
            return False
        d += 1
    return True


def mysterious_light(N: int, X: int)->int:
    if is_prime(N):
        return 3*(N-1)
    return 3*(N-X)


if __name__ == "__main__":
    N, X = map(int, input().split())

    ans = mysterious_light(N, X)
    print(ans)


Failing test case input:
129 2

Expected output:
384


Actual output:
381


Fixed submission (verdict: Accepted):
def gcd(a: int, b: int)->int:
    if a < b:
        a, b = b, a
    return a if b == 0 else gcd(b, a % b)


def mysterious_light(N: int, X: int)->int:
    g = gcd(N, X)
    return 3 * max(N-g, g)


if __name__ == "__main__":
    N, X = map(int, input().split())

    ans = mysterious_light(N, X)
    print(ans)

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,x = map(int,input().split())
import math

def f(x,y):
    a = min(x,y)
    b = max(x,y)    
    if a == 0:
        return 0
    elif b%a == 0:
        return 2*b-1
    else:
        return 2*a*math.floor(b/a) + f(a,b%a)

print(n+f(x,n-x))

Failing test case input:
75 3

Expected output:
216


Actual output:
218


Fixed submission (verdict: Accepted):
n,x = map(int,input().split())
import math

def f(x,y):
    a = min(x,y)
    b = max(x,y)    
    if a == 0:
        return 0
    elif b%a == 0:
        return 2*b-a
    else:
        return 2*a*math.floor(b/a) + f(a,b%a)

print(n+f(x,n-x))

Problem: p04048
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N, X = list(map(int, input().split()))

ans = N
N, X = X, N - X
while N and X:
  if X > N:
    d, m = divmod(X, N)
    ans += d * 2 * N
    N, X = N + m, X - d * N
  else:
    d, m = divmod(N, X)
    ans += d * X + m * 2
    N, X = m, X - m

print(ans)

Failing test case input:
150 3

Expected output:
441


Actual output:
444


Fixed submission (verdict: Accepted):
N, X = list(map(int, input().split()))

ans = N
N, X = X, N - X
while N and X:
  if X > N:
    d, m = divmod(X, N)
    if m == 0:
      ans += (d * 2 - 1) * N
    else:
      ans += d * 2 * N
    N, X = N, m
  else:
    d, m = divmod(N, X)
    if m == 0:
      ans += (d * 2 - 1) * X
    else:
      ans += d * 2 * X + m * 2
    N, X = m, X - m

print(ans)
Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def calc(a,b,ans):
  if b==0:
    return ans
  else:
    if b!=1:
      return calc(b,a%b,ans+b*3)
    else:
      return calc(b,a%b,ans+a*3)

n,x=map(int,input().split())
n=n-x
n,x=max(n,x),min(n,x)
print(calc(n,x,0))

Failing test case input:
260 3

Expected output:
777


Actual output:
21


Fixed submission (verdict: Accepted):
def calc(a,b,ans):
  if b==0:
    return ans
  else:
    return calc(b,a%b,ans+b*(a

n,x=map(int,input().split())
n=n-x
n,x=max(n,x),min(n,x)
print(calc(n,x,0))

Problem: p04048
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, x = map(int, input().split())
print(3 * x if n / x == 2 else 3 * (n - 1))

Failing test case input:
249 3

Expected output:
738


Actual output:
744


Fixed submission (verdict: Accepted):
import math

n, x = map(int, input().split())
print(3 * (n - math.gcd(n, x)))

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
NX = input()
NX = "".join(NX).split(" ")
NX = [int(s) for s in NX]
N =NX[0]
X =NX[1]
D = NX[0]-NX[1]
A=X+D
def ans(x,y):
	global A
	A +=int(x/y)*y+y
	if x%y==0:
		return print(A)
	ans(y,x%y)

if X>D:
	ans(X,D)
else:	ans(D,X)


Failing test case input:
84 3

Expected output:
243


Actual output:
168


Fixed submission (verdict: Accepted):
NX = input()
NX = "".join(NX).split(" ")
NX = [int(s) for s in NX]
N =NX[0]
X =NX[1]
D = NX[0]-NX[1]
A=X+D
def ans(x,y):
	global A
	if x%y==0:
		A+=2*y*(x/y)-y
		return print(int(A))
	A +=int(x/y)*y*2

	ans(y,x%y)

if X>D:
	ans(X,D)
else:	ans(D,X)

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def calc(a,b,ans):
  if b==0:
    return ans
  else:
    if b!=1:
      return calc(b,a%b,ans+b*3)
    else:
      return calc(b,a%b,ans+a*3)

n,x=map(int,input().split())
n,x=max(n,x),min(n,x)
print(calc(n,x,0))

Failing test case input:
92 3

Expected output:
273


Actual output:
21


Fixed submission (verdict: Accepted):
def calc(a,b,ans):
  if b==0:
    return ans
  else:
    return calc(b,a%b,ans+b*(a

n,x=map(int,input().split())
n=n-x
n,x=max(n,x),min(n,x)
print(calc(n,x,0))

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

def func(a,b):
    if a<=b :
        if b%a > 0:
            return 2*math.floor(b/a)*a+func(a,b%a)
        else:
            return 2*math.floor(b/a)*a-1
    else:
        return func(b,a)
N,X = map(int,input().split())

dis =N 
dis += func(N-X,X)
print(dis)

Failing test case input:
202 2

Expected output:
600


Actual output:
601


Fixed submission (verdict: Accepted):

def gcd(a,b):
    if a==b:
        return b
    elif a%b== 0:
        return b
    else:
        return gcd(b,a%b)

import math

def func(a,b):
    if a<=b :
        if b%a != 0:
            return 2*math.floor(b/a)*a+func(a,b%a)
        else:
            return 2*(math.floor(b/a))*a-a
    else:
        return func(b,a)
N,X = map(int,input().split())

dis =N 
dis += func(N-X,X)
dis1 = 3*(N-gcd(N,X))
print(dis)
Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, x = map(int, input().split())
ans, e = (x, x) if(x*2 > n) else (n, n-x)
while x > 0:
    ans += e/(x/2)
    e, x = x, e%x
print(int(ans))


Failing test case input:
843 1

Expected output:
2526


Actual output:
2527


Fixed submission (verdict: Accepted):
n, x = map(int, input().split())
ans, e = n, n-x
while x > 0:
    ans += x * (e
    e, x = x, e%x
print(ans-e)

Problem: p04048
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from math import floor
N, X = [int(x) for x in input().split()]

y = N-X
x = X
L = X
while x > 0:
	k = 2*floor(y/x)
	L += x*k

	y, x = (x, y-x)

print(L)

Failing test case input:
228 1

Expected output:
681


Actual output:
455


Fixed submission (verdict: Accepted):

from math import floor
N, X = [int(x) for x in input().split()]

y = N-X
x = X
L = X
while x > 0:

	k, z = divmod(y, x)

	L += x*(2*k-1)+y

	y, x = (x, z)


print(L)

Problem: p04048
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N, X = list(map(int, input().split()))

ans = N
N, X = X, N - X
while N and X:
  if X > N:
    d, m = divmod(X, N)
    if m == 0:
      ans += (d * 2 - 1) * N
    else:
      ans += d * 2 * N
    N, X = N, m
  else:
    d, m = divmod(N, X)
    ans += (d * 2 - 1) * X + m * 2
    N, X = m, X - m

print(ans)

Failing test case input:
23 8

Expected output:
66


Actual output:
59


Fixed submission (verdict: Accepted):
N, X = list(map(int, input().split()))

ans = N
N, X = X, N - X
while N and X:
  if X > N:
    d, m = divmod(X, N)
    if m == 0:
      ans += (d * 2 - 1) * N
    else:
      ans += d * 2 * N
    N, X = N, m
  else:
    d, m = divmod(N, X)
    if m == 0:
      ans += (d * 2 - 1) * X
    else:
      ans += d * 2 * X + m * 2
    N, X = m, X - m

print(ans)
Problem: p02617
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
edge = 0
for i in range(N-1):
    u,v = map(int,input().split())
    edge += u*(N-v+1)

vertice = 0    
for i in range(1,N+1):
    vertice += i*(N-i+1)
    
print(vertice-edge)

Failing test case input:
10
1 29
5 12
-2 4
0 3
7 2
4 7
13 4
6 2
7 1

Expected output:
227


Actual output:
-37


Fixed submission (verdict: Accepted):
N = int(input())
edge = 0
for i in range(N-1):
    u,v = map(int,input().split())
    if u > v:
        a = u
        u = v
        v = a
    edge += u*(N-v+1)

vertice = 0    
for i in range(1,N+1):
    vertice += i*(N-i+1)
    
print(vertice-edge)

Problem: p02617
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
mod = 10**9+7
ans = 0
for i in range(1,n+1):
  ans += i*(n-i+1)
for a,b in ab:
  if a > b:
    a,b = b,a
  ans -= a*(n-b+1)
  ans %= mod
print(ans)

Failing test case input:
3
0 0
-1 18

Expected output:
-4


Actual output:
1000000003


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
ans = 0
for i in range(1,n+1):
  ans += i*(n-i+1)
for a,b in ab:
  if a > b:
    a,b = b,a
  ans -= a*(n-b+1)
print(ans)

Problem: p02617
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
ans=0
for i in range(1,n+1):
    ans += i*(i+1)/2
for i in range(n-1):
    u,v=map(int,input().split())
    if u > v:
        u,v=v,u
    ans -= u*(n-v+1)
print(ans)

Failing test case input:
10
1 41
1 4
-2 1
1 2
9 1
0 7
0 3
14 3
8 0

Expected output:
261


Actual output:
261.0


Fixed submission (verdict: Accepted):
n=int(input())
ans=0
for i in range(1,n+1):
    ans += i*(i+1)/2
for i in range(n-1):
    u,v=map(int,input().split())
    if u > v:
        u,v=v,u
    ans -= u*(n-v+1)
print(int(ans))

Problem: p02617
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())

ans = 0

for i in range(1,n+1): 
    ans += i*(n-i+1)
    print(ans)

for _ in range(n-1): 
    u,v = map(int, input().split())
    if u > v: 
        u,v = v,u
    ans -= u*(n-v+1)
    print(ans)
print(ans)

Failing test case input:
10
1 29
5 4
-2 1
0 3
5 2
4 7
13 5
14 2
9 1

Expected output:
220


Actual output:
10
28
52
80
110
140
168
192
210
220
238
214
234
234
222
206
216
222
220
220


Fixed submission (verdict: Accepted):


n = int(input())

ans = 0

for i in range(1,n+1): 
    ans += i*(n-i+1)
    

for _ in range(n-1): 
    u,v = map(int, input().split())
    if u > v: 
        u,v = v,u
    ans -= u*(n-v+1)
    
print(ans)
Problem: p02632
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
mod = pow(10, 9) + 7
K = int(input())
S = input()
n = len(S)
tmp = pow(26, K, mod)
waru = pow(26, -1)
ans = tmp
for i in range(1, K+1):
    tmp = (tmp * 25 * waru)%mod
    tmp = (tmp * (i + n -1) * pow(i, -1))%mod
    ans = (ans+tmp)%mod
print(int(ans%mod))

Failing test case input:
37564
tmguhr{lcdddtduxd

Expected output:
318008117


Actual output:
78287136


Fixed submission (verdict: Accepted):

import sys
MOD = 10**9+7
K = int(input())
S = input()
l = len(S)
ans = 0
 
tmp = pow(26,K,MOD)
ans = tmp
waru = pow(26,-1,MOD)
 
for i in range(1,K+1):
    tmp = (tmp*25*waru)%MOD
    tmp = (tmp*(l-1+i)*pow(i,-1,MOD))%MOD
    ans = (ans+tmp)%MOD
 
print(ans)

Problem: p02632
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from sys import stdin
input = stdin.readline
def nCr(n,r):
    return fact[n]*(inv[n-r]%M)*(inv[r]%M)
M = 1000000007
k = int(input())
s = len(input())
t = k+s
fact = [1]
p25 = [1]
for i in range(1,t+1):
    fact += [(fact[-1] * i)%M]
    if i<=k:
        p25  += [(p25[-1] * 25) % M]

inv = [1]*(t+1)
inv[t] = pow(fact[t], M-2, M)
for i in range(t-1, -1, -1):
    inv[i] = inv[i+1] * (i+1) % M


res = 0
for i in range(k+1):
    res+=nCr(t,t-i)*p25[i]
    res%=M
print(res)

Failing test case input:
37564
dxcdtuddcm{rhugnt

Expected output:
318008117


Actual output:
917760936


Fixed submission (verdict: Accepted):
def nCr(n,r):
    return fact[n]*(inv[n-r]%M)*(inv[r]%M)
M = 1000000007
k = int(input())
s = len(input())
t = k+s
fact = [1]
p25 = [1]
for i in range(1,t+1):
    fact += [(fact[-1] * i)%M]
    if i<=k:
        p25  += [(p25[-1] * 25) % M]

inv = [1]*(t+1)
inv[t] = pow(fact[t], M-2, M)
for i in range(t-1, -1, -1):
    inv[i] = inv[i+1] * (i+1) % M


res = 0
for i in range(k+1):
    
    res+=nCr(t,t-i)*p25[i]
    
    res%=M
    
print(res)
Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=list(input())
mod=10**9+7
ans=0
z=list(set(s))
m=len(z)
for i in range(m):
    ans+=s.count(z[i])*(2**(m-i-1))%mod
print(ans%mod)

    


Failing test case input:
4
bbbd

Expected output:
7


Actual output:
5


Fixed submission (verdict: Accepted):
n=int(input())
s=list(input())
mod=10**9+7
z=list(set(s))
ans=1

m=len(z)
for i in range(m):   
    ans*=(s.count(z[i])+1)%mod
    ans=ans%mod
print((ans-1)%mod)

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import collections
N=int(input())
S=str(input())
Slist=list(S)
c = collections.Counter(Slist)
d = c.most_common()
dlen=len(d)
count=-1
for i in range(dlen):
    count+=d[i][1]+1
count%=1000000007
print(count)

Failing test case input:
5
aabbb

Expected output:
11


Actual output:
6


Fixed submission (verdict: Accepted):

import collections
N=int(input())
S=str(input())
Slist=list(S)
c = collections.Counter(Slist)
d = c.most_common()
dlen=len(d)
count=1
for i in range(dlen):
    count*=(d[i][1]+1)
count-=1
count%=1000000007
print(count)

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
str_dict = {}

for s in S:
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] = str_dict[s] + 1

single_char = {k: v for k, v in str_dict.items() if v == 1}
multiple_char = {k: v for k, v in str_dict.items() if v != 1}
single_char_num = len(single_char)

base_permutation = (2 ** single_char_num - 1) % (10 ^ 9 + 7)

all_permutation = base_permutation + 1
for v in multiple_char.values():
    all_permutation = all_permutation * (v + 1) % (10 ^ 9 + 7)
all_permutation = all_permutation - 1

print(all_permutation % (10 ^ 9 + 7))

Failing test case input:
5
bdacf

Expected output:
31


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
str_dict = {}

for s in S:
    if s not in str_dict:
        str_dict[s] = 1
    else:
        str_dict[s] = str_dict[s] + 1

single_char = {k: v for k, v in str_dict.items() if v == 1}
multiple_char = {k: v for k, v in str_dict.items() if v != 1}
single_char_num = len(single_char)

base_permutation = 2 ** single_char_num % (10 ** 9 + 7)

all_permutation = base_permutation
for v in multiple_char.values():
    all_permutation = all_permutation * (v + 1)
all_permutation = all_permutation - 1

print(all_permutation % (10 ** 9 + 7))

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter


s = input()

counter = Counter(s)

result = 1
for _, freq in counter.items():
    result *= (freq + 1)

print((result - 1) % 1000000007)


Failing test case input:
3
aba

Expected output:
5


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import Counter

N = int(input())
s = input()

counter = Counter(s)

result = 1
for _, freq in counter.items():
    result *= (freq + 1)

print((result - 1) % 1000000007)
Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
for t in range(1):
	n=int(input())
	s=input()
	freq=[0]*(26)
	ct=0
	for i in range(len(s)):
		freq[ord(s[i])-ord('a')]+=1
		if freq[ord(s[i])-ord('a')]==1:
			ct+=1
	ans=1
	for i in range(26):
		if freq[i]>0:
			ans=(ans*freq[i])%1000000007
	print(ans)



Failing test case input:
4
bade

Expected output:
15


Actual output:
1


Fixed submission (verdict: Accepted):
for t in range(1):
	n=input()
	s=input()
	freq=[0]*(26)
	ct=0
	for i in range(len(s)):
		freq[ord(s[i])-ord('a')]+=1
		if freq[ord(s[i])-ord('a')]==1:
			ct+=1
	ans=1
	for i in range(26):
		if freq[i]>0:
			ans=(ans*(freq[i]+1))
	print((ans-1)%1000000007)

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = str(input())
l = []
for x in s:
    if x not in l:
        l.append(x)
ans = 1
for x in l:
    ans = ans*(s.count(x)+1)
ans =- 1
ans %= 10**9 + 7
print(ans-1)

Failing test case input:
4
bbbb

Expected output:
4


Actual output:
1000000005


Fixed submission (verdict: Accepted):
n = int(input())
s = str(input())
l = []
for x in s:
    if x not in l:
        l.append(x)
ans = 1
for x in l:
    ans = ans*(s.count(x)+1)
ans -= 1
ans = ans%(10**9 + 7)
print(ans)

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%10**9+7)

Failing test case input:
4
dbbb

Expected output:
7


Actual output:
14


Fixed submission (verdict: Accepted):
from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
s = str(input())
b = 10 ** 9 + 7 



sum=0
alphabet=['a', 'b', 'c', 'd' ]
alphabet=[chr(i) for i in range(97, 97 + 26)]
for i in alphabet:
    count=s.count(i)
    sum = (sum * (count + 1) + count ) % b     
    print (s,i,count,sum)
print(sum)


Failing test case input:
4
ecab

Expected output:
15


Actual output:
ecab a 1 1
ecab b 1 3
ecab c 1 7
ecab d 0 7
ecab e 1 15
ecab f 0 15
ecab g 0 15
ecab h 0 15
ecab i 0 15
ecab j 0 15
ecab k 0 15
ecab l 0 15
ecab m 0 15
ecab n 0 15
ecab o 0 15
ecab p 0 15
ecab q 0 15
ecab r 0 15
ecab s 0 15
ecab t 0 15
ecab u 0 15
ecab v 0 15
ecab w 0 15
ecab x 0 15
ecab y 0 15
ecab z 0 15
15


Fixed submission (verdict: Accepted):

n = int(input())
s = str(input())
b = 10 ** 9 + 7 



sum=0
alphabet=['a', 'b', 'c', 'd' ]
alphabet=[chr(i) for i in range(97, 97 + 26)]
for i in alphabet:
    count=s.count(i)
    sum = (sum * (count + 1) + count ) % b     
    
print(sum)
Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
_=input()
S=input()


obj={}
L=[]
r=1
for i in S:
    if i in L:
        obj[i]+=1
        r=r*int((1+1/(2**obj[i])))
    else:
        r*=2
        obj[i]=0
        L.append(i)

    if r>(10**9+7):
        r-=(10**9+7)
        
print(r-1)


Failing test case input:
5
babaa

Expected output:
11


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
R=""
L=[]
obj={}
for s in S:
    if s not in L:
        R+=s
        L.append(s)
        obj[s]=1
    else:
        obj[s]+=1

out=1
for a in obj.keys():
    out*=(obj[a]+1)
    if out>10**9+7:
        out=out%(10**9+7)
print(out-1)

Problem: p03095
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = input()
M = 10**9 + 7

from collections import Counter

cs = Counter(S)
ans = 1
for key, val in cs.items():
    ans *= (val + 1)
ans%= M
ans -= 1

Failing test case input:
4
adba

Expected output:
11


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())
S = input()
M = 10**9 + 7

from collections import Counter

cs = Counter(S)
ans = 1
for key, val in cs.items():
    ans *= (val + 1)
ans %= M
ans -= 1
print(ans)

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

n = int(input())
s = input()

cnt = Counter(list(s))
num = 1
for i in cnt.values():
    num = (num * (i+1)) % (1e09 + 7)

print(num - 1)

Failing test case input:
3
aaa

Expected output:
3


Actual output:
3.0


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())
s = input()

cnt = Counter(list(s))
num = 1
for i in cnt.values():
    num = num * (i+1)

out = (num - 1) % int(1e09 + 7)
print(out)

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections as c

N=int(input())
S=list(input())

S=list(c.Counter(S).items())
print(S)

ans=1
for s in S:
  ans*=(s[1]+1)
print((ans-1)%(10**9+7))

Failing test case input:
4
adba

Expected output:
11


Actual output:
[('a', 2), ('d', 1), ('b', 1)]
11


Fixed submission (verdict: Accepted):
import collections as c

N=int(input())
S=list(input())

S=list(c.Counter(S).items())


ans=1
for s in S:
  ans*=(s[1]+1)
print((ans-1)%(10**9+7))

Problem: p03095
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
KIND = 26
l=int(input())
s=input()

alpha_list = []
for i in range(0, KIND):
    alpha_list.append(0)

for i in s:
    alpha_list[ord(i)-ord('a')] += 1

ret = 1
for num in alpha_list:
    ret *= (num + 1)
print((ret-1)/100000000+7)


Failing test case input:
4
ceba

Expected output:
15


Actual output:
7.00000015


Fixed submission (verdict: Accepted):
KIND = 26
l=int(input())
s=input()

alpha_list = []
for i in range(0, KIND):
    alpha_list.append(0)

for i in s:
    alpha_list[ord(i)-ord('a')] += 1

ret = 1
for num in alpha_list:
    ret *= (num + 1)
print((ret-1)%(1000000000+7))