Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b), else "NO")


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if len(a) == len(b), else "NO")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if a.count(a[i])>=2:
    res="NO"
    break
print(res)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if i.count(a[i])>=2:
    res="NO"
    break
print(res)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if a.count(a[i])>=2:
    res="NO"
print(res)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if i.count(a[i])>=2:
    res="NO"
print(res)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")
Buggy python submission (verdict: Runtime Error):
h,n= map(int, input().split())
a = sum(list(map(int,input().split())))
print("Yes" if h-a <=0 else "No")

Fixed submission:
h, a = map(int, input().split())
print(h//a if h % a == 0 else h//a +1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
ans=0
for i in range(n):
    if a[i]==min(a[:i+1]):
        ans+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
m=a[0]
ans=0
for i in range(n):
    x=a[i]
    if x<=m:
        ans+=1
        m=x
print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
ls = [1,2,3]
del ls[a-1]
del ls[b-1]
print(max(ls))

Fixed submission:
a =sorted( [int(input()) for i in range(2)])
print("1" if a == [2,3] else "2" if a == [1,3] else "3")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
ls = [1,2,3]
del ls[a-1]
del ls[b-1]
print(ls)

Fixed submission:
a =sorted( [int(input()) for i in range(2)])
print("1" if a == [2,3] else "2" if a == [1,3] else "3")
Buggy python submission (verdict: Runtime Error):
n=int(input())
def eratos(n):
   prime_list =set ()
   num_list=set()
   for i in range(2, int(n**0.5)+1):
       if i not in num_list:
           prime_list.add(i)
           for j in range(i*i, n+1, i):
               num_list.add(j)
   return(prime_list)
print(s)
x=int(n**0.5)
while 1:
    if x in s and n%x==0:
        break
    x-=1
print(x+(n//x)-2)

Fixed submission:
n=int(input())
a=1
ans=n
while a*a<=n:
    if n%a==0:
        ans=min(a+n//a-2,ans)
    a+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))
for i in range(1,n+1):
    print(a.index(i)+1)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
ans=[0]*n
for i in range(n):
    ans[a[i]-1]=i+1
print(*ans)
Buggy python submission (verdict: Runtime Error):
n,l= map(int,input().split())
aj=[l + i  for i in range(n)]
ajs = sum(aj)
resl = []
for i in range(n):
    aj2 = aj
    del aj2[i]
    resl += [sum(aj2)]
resl2 = [abs(ajs-resl[i]) for i in range(n)]
x = resl2.index(min(resl2))
print(aj[x])

Fixed submission:
n,l = map(int,input().split())
aji = [l+i for i in range(n)]
mn= 100
for i in range(n):
    mn= min(mn,abs(aji[i]))
if mn in aji:del aji[aji.index(mn)]
else:del aji[aji.index(-mn)]
print(sum(aji))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
denkyu_switch=[]
res=0
for i in range(m):
    denkyu_switch+=[list(map(int, input().split()))[1:]]
p=list(map(int, input().split()))
for i in range(2**n):
    denkyu = [0] * m
    for j in range(n):
        if i>>j & 1:
            for k in denkyu_switch:
                if j in k:
                    denkyu[k]+=1
    if p==denkyu:
        res+=1
print(res)


Fixed submission:
n,m=map(int,input().split())
denkyu_switch=[]
res=0
for i in range(m):
    denkyu_switch+=[list(map(int, input().split()))[1:]]
p=list(map(int, input().split()))
for i in range(2**n):
    denkyu = [0] * m
    for j in range(n):
        if i>>j & 1:
            for k in range(m):
                if j+1 in denkyu_switch[k]:
                    denkyu[k]+=1
    denkyu2=[i%2 for i in denkyu]
    if p==denkyu2:
        res+=1
print(res)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = input()
ans = [s[:k],s[k].lower(),s[k+1:]]
print(''.join(ans))




Fixed submission:
n,k = map(int, input().split())
s = input()
ans = [s[:k-1],s[k-1].lower(),s[k:]]
print(''.join(ans))
Buggy python submission (verdict: Runtime Error):
a,b,c,d,e = map(int,input().split())
k = int(input())
print("Yay!" if e-a<= k else ":(")

Fixed submission:
a,b,c,d,e,k= int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
print("Yay!" if e-a<= k else ":(")

Buggy python submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
k = int(input())
print("Yay!" if e-a<= k else ":(")

Fixed submission:
a,b,c,d,e,k= int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
print("Yay!" if e-a<= k else ":(")

Buggy python submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]
k = int(input())
print("Yey!" if e-a<= k else ":(")

Fixed submission:
a,b,c,d,e,k= int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
print("Yay!" if e-a<= k else ":(")
Buggy python submission (verdict: Runtime Error):
s=list(input())
dna = ["A","T","G","C"]
res=[]
x=0
for i in range(len(s)):
    if s[i] in dna:
        x+=1
    else:
        res+=[x]
        x=0
print(max(res))

Fixed submission:
s=list(input())
dna = ["A","T","G","C"]
res=[0]
x=0
for i in range(len(s)):
    if s[i] in dna:
        x+=1
    else:
        res+=[x]
        x=0
print(max(x,max(res)))
Buggy python submission (verdict: Runtime Error):
s=input()
res="AC"
if s[0]=="A":res="WA"
elif s[2:-2].count("C")!=1:res="WA"
else:
    li=list(s)
    li.remove("A")
    li.remove("C")
    for i in li:
        if i!=i.lower():
            res="WA"
print(res)

Fixed submission:
s=input()
res="AC"
if s[0]!="A":res="WA"
elif s[2:-1].count("C")!=1:res="WA"
else:
    li=list(s)
    li.remove("A")
    li.remove("C")
    for i in li:
        if i!=i.lower():
            res="WA"
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k=map(int,input().split())
la=[i for i in range(a,b+1)]
if k*2>=(b-a+1):res=la
else:res = la[:k]+la[-k:]
print(*res)

Fixed submission:
a,b,k=map(int,input().split())
if k*2>=(b-a+1):
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):print(i)
    for i in range(b-k+1,b+1):print(i)
Buggy python submission (verdict: Runtime Error):
print(int(input)//3)

Fixed submission:
print(int(input())//3)
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n==1:print(2)
elif n==2:print(1)
else:
    nu1=2
    nu2=1
    for i in range(n-1):
        nu3=nu1+nu2
        nu1=nu2
        nu2=nu3
print(nu3)

Fixed submission:
n=int(input())
if n==0:
    print(2)
    exit()
elif n==1:
    print(1)
    exit()
else:
    nu1=2
    nu2=1
    for i in range(n-1):
        nu3=nu1+nu2
        nu1=nu2
        nu2=nu3
print(nu3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(n*(n+1)//2)

Fixed submission:
a = sorted(list(map(int, input().split())))
print("YES" if a[1] == 5 and a[0]== 5 and a[2] else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input().split()
ans=1
for i in range(n):
  ans*=int(a[i])
if ans>1e18:
  print(-1)
else:
  print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
  print(0)
  exit()
ans=1
for i in range(n):
  ans*=a[i]
  if ans>10**18:
    print(-1)
    exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
X = input()
x = 100
for i in range(5000):
  x = x * 101 / 100
  if x >= X:
    print i + 1
    break

Fixed submission:
X = int(input())
x = int(100)
for i in range(5000):
  x = int(x * 101 / 100)
  if x >= X:
    print(i + 1)
    break
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd

n = int(input())


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


pp = set()
a = [int(i) for i in input().split()]

j = 0
for i in a:
    j = gcd(j, i)
ok1 = j == 1

ok2 = True
for i in a:
    for (j, _) in p(i):
        if j in pp:
            ok2 = False
        else:
            pp.add(j)
if ok2:
    print("pairwise coprime")
else:
    if ok1:
        print("setwise coprime")
    else:
        print("not coprime")


Fixed submission:
from math import gcd

n = int(input())


def p(x):
    a = []
    i = 2
    while True:
        if x % i == 0:
            j = 0
            while x % i == 0:
                x //= i
                j += 1
            a.append((i, j))
        if i * i > x:
            break
        i += 1
    if x != 1:
        a.append((x, 1))
    return a


pp = set()
a = [int(i) for i in input().split()]

j = 0
for i in a:
    j = gcd(j, i)
ok1 = j == 1

ma = 2*10**6
table = [0]*ma
for i in a:
    table[i] += 1
ok2 = True
for i in range(2,ma):
    s = 0
    for j in range(i,ma,i):
        s += table[j]
    if s>1:
        ok2 = False

if ok2:
    print("pairwise coprime")
else:
    if ok1:
        print("setwise coprime")
    else:
        print("not coprime")
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
if k % 2 == 0:
    print(-1)
    exit()
a = 7
ans = 1
while True:
    if a % k == 0:
        print(ans)
        exit()
    a = (a*10+7) % k
    ans += 1


Fixed submission:
k = int(input())
if k % 2 == 0 or k%5==0:
    print(-1)
    exit()
a = 7
ans = 1
while True:
    if a % k == 0:
        print(ans)
        exit()
    a = (a*10+7) % k
    ans += 1
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += np.sum(np.arange(i, n+1, i, dtype=np.int64))
print(ans)


Fixed submission:
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += (n//i) * (i + n // i * i) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d=map(int,input().split());m=998244353;D=[[0]*(d+1)for _ in range(c+1)];D[a][b]=1
for i in range(c):
 for j in range(d):D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%m
print(D[c][d])

Fixed submission:
ma = 3010
dp = [[0] * ma for _ in range(ma)]
mod = 998244353


a, b, c, d = map(int, input().split())
dp[a][b] = 1
for i in range(b+1, ma):
    dp[a][i] = dp[a][i - 1] * a % mod
for i in range(a+1, ma):
    dp[i][b] = dp[i - 1][b] * b % mod


for i in range(a+1, ma):
    for j in range(b+1, ma):
        dp[i][j] = (-dp[i - 1][j - 1] * (i-1)*(j-1) +
                    dp[i - 1][j] * j + dp[i][j - 1] * i) % mod
print(dp[c][d])
Buggy python submission (verdict: Runtime Error):
h, w, k = map(int, input().split())
x1, y1, x2, y2 = [int(i)-1 for i in input().split()]
ans = [[-1] * w for _ in range(h)]
ans[x1][y1] = 0
c = [input() for _ in range(h)]
qu = [(x1, y1)]


for x, y in qu:
    if x == x2 and y == y2:
        print(ans[x2][y2])
        break

    for i in range(x + 1, min(x + k + 1, h)):
        if c[i][y] == "@":
            break
        if ans[i][y] == -1:
            ans[i][y] = ans[x][y] + 1
            qu.append((i, y))
    for i in reversed(range(max(0, x - k), x)):
        if c[i][y] == "@":
            break
        if ans[i][y] == -1:
            ans[i][y] = ans[x][y] + 1
            qu.append((i, y))

    for i in range(y + 1, min(y + k + 1, w)):
        if c[x][i] == "@":
            break
        if ans[x][i] == -1:
            ans[x][i] = ans[x][y] + 1
            qu.append((x, i))
    for i in reversed(range(max(0, y - k), x)):
        if c[x][i] == "@":
            break
        if ans[x][i] == -1:
            ans[x][i] = ans[x][y] + 1
            qu.append((x, i))
else:
    print(-1)


Fixed submission:
h, w, k = map(int, input().split())
x1, y1, x2, y2 = [int(i)-1 for i in input().split()]
ans = [[-1] * w for _ in range(h)]
ans[x1][y1] = 0
c = [input() for _ in range(h)]
qu = [(x1, y1)]


for x, y in qu:
    if x == x2 and y == y2:
        print(ans[x2][y2])
        break

    for i in range(x + 1, min(x + k + 1, h)):
        if c[i][y] == "@":
            break
        if ans[i][y] == -1:
            ans[i][y] = ans[x][y] + 1
            qu.append((i, y))
        elif ans[i][y] <= ans[x][y]:
            break
    for i in reversed(range(max(0, x - k), x)):
        if c[i][y] == "@":
            break
        if ans[i][y] == -1:
            ans[i][y] = ans[x][y] + 1
            qu.append((i, y))
        elif ans[i][y] <= ans[x][y]:
            break

    for i in range(y + 1, min(y + k + 1, w)):
        if c[x][i] == "@":
            break
        if ans[x][i] == -1:
            ans[x][i] = ans[x][y] + 1
            qu.append((x, i))
        elif ans[x][i] <= ans[x][y]:
            break
    for i in reversed(range(max(0, y - k), y)):
        if c[x][i] == "@":
            break
        if ans[x][i] == -1:
            ans[x][i] = ans[x][y] + 1
            qu.append((x, i))
        elif ans[x][i] <= ans[x][y]:
            break
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, s = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
mod = 998244353
dp = [0] * (s + 1)
dp[0] = 1
for i in a:
    dp2 = [0] * (s + 1)
    for j in range(s + 1):
        dp2[j] = dp[j] * 2
        if j >= i:
            dp2[j] += dp[j - i]
        dp2[j] %= mod
    dp = dp2
print(dp[-1])


Fixed submission:
n, s = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
mod = 998244353
dp = [0] * (s + 1)
dp[0] = 1
for i in a:
    dp2 = [0] * (s + 1)
    for j in range(s + 1):
        dp2[j] = dp[j] * 2
        if j >= i:
            dp2[j] += dp[j - i]
        dp2[j] %= mod
    dp = dp2
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(i) for i in input().split()]
a = [int(i)-1 for i in input().split()]
x = list(range(n))

def calc(a, b):
    c = [0] * n
    for i in range(n):
        c[i] = b[a[i]]
    return c

while k:
    if k & 1 == 1:
        x = calc(x, a)
    k //= 2
    a = calc(a, a)

print(x[0]+1)

Fixed submission:
n, k = [int(i) for i in input().split()]
a = [int(i)-1 for i in input().split()]

if k <= n:
    i = 0
    for _ in range(k):
        i = a[i]
    print(i + 1)
    exit()

visit = [False] * n
visit[0] = True
lon = [0] * n

i = 0
l = 0
while True:
    i = a[i]
    l += 1
    if visit[i]:
        break
    visit[i] = True
    lon[i] = l

kk = (k - lon[i]) % (l - lon[i])
for _ in range(kk):
    i = a[i]
print(i+1)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations_with_replacement as c
n, m, q = [int(i) for i in input().split()]
abc = [[int(i) for i in input().split()] for _ in range(q)]
aa = list(range(1,m+1))
ans = 0
for bb in c(aa,m):
    cc = 0
    for a, b, c, d in abc:
        if bb[b-1] - bb[a-1] == c:
            cc += d
    ans = max(ans, cc)
print(ans)

Fixed submission:
from itertools import combinations_with_replacement as c
n, m, q = [int(i) for i in input().split()]
abc = [[int(i) for i in input().split()] for _ in range(q)]
aa = list(range(1,m+1))
ans = 0
for bb in c(aa, n):
    cc = 0
    for a, b, c, d in abc:
        if bb[b-1] - bb[a-1] == c:
            cc += d
    ans = max(ans, cc)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m, s = [int(i) for i in input().split()]

e = []
for _ in range(m):
    u, v, a, b = [int(i) for i in input().split()]
    u -= 1
    v -= 1
    e.append([u, v, a, b])

co = [[int(i) for i in input().split()] for _ in range(n)]

dp = [[10 ** 18] * 6000 for _ in range(n)]
dp[0][s] = 0
for i in range(6000):
    if i + co[0][0] < 6000:
        dp[0][i + co[0][0]] = min(dp[0][i + co[0][0]], dp[0][i] + co[0][1])

for _ in range(n):
    for u, v, a, b in e:
        for j in range(a, 6000):
            dp[v][j - a] = min(dp[v][j - a], dp[u][j] + b)
        for i in range(6000):
            if i + co[v][0] < 6000:
                dp[v][i + co[v][0]] = min(dp[v][i + co[v][0]], dp[v][i] + co[v][1])

        for j in range(a, 6000):
            dp[u][j - a] = min(dp[u][j - a], dp[v][j] + b)
        for i in range(6000):
            if i + co[u][0] < 6000:
                dp[u][i + co[u][0]] = min(dp[u]
                                          [i + co[u][0]], dp[u][i] + co[u][1])

for i in range(1, n):
    print(min(dp[i]))

Fixed submission:
n, m, s = [int(i) for i in input().split()]

e = []
for _ in range(m):
    u, v, a, b = [int(i) for i in input().split()]
    u -= 1
    v -= 1
    e.append([u, v, a, b])

co = [[int(i) for i in input().split()] for _ in range(n)]

dp = [[10 ** 18] * 6000 for _ in range(n)]
dp[0][min(5999,s)] = 0
for i in range(6000):
    if i + co[0][0] < 6000:
        dp[0][i + co[0][0]] = min(dp[0][i + co[0][0]], dp[0][i] + co[0][1])

for _ in range(n):
    for u, v, a, b in e:
        for j in range(a, 6000):
            dp[v][j - a] = min(dp[v][j - a], dp[u][j] + b)
        for i in range(6000):
            if i + co[v][0] < 6000:
                dp[v][i + co[v][0]] = min(dp[v][i + co[v][0]], dp[v][i] + co[v][1])

        for j in range(a, 6000):
            dp[u][j - a] = min(dp[u][j - a], dp[v][j] + b)
        for i in range(6000):
            if i + co[u][0] < 6000:
                dp[u][i + co[u][0]] = min(dp[u]
                                          [i + co[u][0]], dp[u][i] + co[u][1])

for i in range(1, n):
    print(min(dp[i]))
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll (i)=0;(i)<(n);(i)++)

bool is(string s, int i, int j) {
    for (int l = 0; l <= j - i; l++) {
        if (s[l + i] != s[j - l]) {
            return false;
        }
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int n;
    n = s.size();
    if (is(s, 0, (n - 1) / 2 - 1) && is(s, 0, n - 1) && is(s, (n + 3) / 2 - 1, n - 1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Fixed submission:
s = input()

def isk(s):
    n = len(s)
    for i in range(n):
        if s[i] != s[n - 1 - i]:
            return False
    return True
n = len(s)
if isk(s) and isk(s[:(n - 1) // 2]) and isk(s[(n + 3) // 2 - 1:]):
    print('Yes')
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from math import sqrt, isclose
a, b, c = [int(i) for i in input().split()]
d = sqrt(c) - sqrt(a) - sqrt(b)
if isclose(d,0) or d<0:
    print("No")
else:
    print("Yes")

Fixed submission:
a, b, c = [int(i) for i in input().split()]
if a + b >= c:
    print("No")
else:
    if 4 * a * b < (c - a - b)** 2:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
from decimal import *
getcontext().prec = 10000
a, b, c = [Decimal(int(i)) for i in input().split()]
if c.sqrt() - a.sqrt() - b.sqrt() < Decimal(-100).exp():
    print("Yes")
else:
    print("No")


Fixed submission:
a, b, c = [int(i) for i in input().split()]
if a + b >= c:
    print("No")
else:
    if 4 * a * b < (c - a - b)** 2:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
s=input()
print("Yes"if s=="hi"*(len(s)//2)else"No)

Fixed submission:
s=input();print("Yes"if s=="hi"*(len(s)//2)else"No")
Buggy python submission (verdict: Runtime Error):
a=1<<1000000000
b = 1<<a
print(b)

Fixed submission:
if len(set([int(i) for i in input().split()])) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = input()
k = len(n)-int(input())

dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(len(n)+1)]

dp[0][0][1] = 1

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


Fixed submission:
n = input()
k = len(n) - int(input())
if k < 0:
    print(0)
    exit()

dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(len(n)+1)]

dp[0][0][1] = 1

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

Buggy python submission (verdict: Runtime Error):
n = input()
k = len(n)-int(input())

dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(len(n)+1)]

dp[0][0][1] = 1

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


Fixed submission:
n = input()
k = len(n) - int(input())
if k < 0:
    print(0)
    exit()

dp = [[[0] * 2 for _ in range(k + 1)] for _ in range(len(n)+1)]

dp[0][0][1] = 1

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