Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, X, M = map(int, input().split())

count = X
bef = X
_sum = [X]
dic = {X: 1}

for i in range(1, N + 1):
    bef = pow(bef, 2, M)
    if bef in dic:
        posi = dic[bef]
        l = len(_sum) - posi
        plus = _sum[-1] - (_sum[posi - 1] if posi - 1 > 0 else 0)
        count += plus * ((N - i) // l)
        mod = ((N - i) % l)
        count += _sum[posi - 1 + mod] - (_sum[posi - 1] if posi - 1 > 0 else 0)
        break
    else:
        dic.setdefault(bef, i)
        _sum.append(bef + _sum[-1])
    count += bef

print(count)

Fixed submission:
N, X, M = map(int, input().split())

count = X
bef = X
_sum = [bef]
dic = {}

for i in range(1, N):
    bef = pow(bef, 2, M)
    if bef in dic:
        posi = dic[bef]
        l = len(_sum) - posi
        plus = sum(_sum[posi:])
        count += plus * ((N - i) // l)
        mod = ((N - i) % l)
        count += sum(_sum[posi:posi + mod])
        break
    else:
        dic.setdefault(bef, i)
        _sum.append(bef)
    count += bef

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7
N = int(input())

A = list(map(int, input().split()))

count = 0
for i in range(len(A)):
    for j in range(i + 1, len(A)):
        count += (A[i] * A[j]) % MOD
        count %= MOD
print(count)

Fixed submission:
MOD = 10**9 + 7
N = int(input())

modsum = 0
A = list(map(int, input().split()))
for a in A:
    modsum = (modsum + a) % MOD

count = 0
for a in A[:-1]:
    modsum -= a
    while modsum < 0:
        modsum = MOD + modsum
    count = (count + (modsum * a) % MOD) % MOD
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

c_list = [s for s in input()]
cr = list(reversed(c_list))
back = N - 1


def check(forward):
    global back
    for i in range(back, -1, -1):
        if i < forward:
            return -1
        if c_list[i] == "R":
            back -= 1
            return i
    return -1


count = 0
for i, c in enumerate(c_list):
    if c_list[i] == "W":
        temp = check(i + 1)
        if temp != -1:
            c_list[i] = "R"
            c_list[temp] = "W"
            count += 1
        else:
            break
print(count)

Fixed submission:
N = int(input())

c_list = [s for s in input()]
back = N - 1


def check(forward):
    global back
    for i in range(back, -1, -1):
        if i < forward:
            return -1
        if c_list[i] == "R":
            back = i - 1
            return i
    return -1


count = 0
for i, c in enumerate(c_list):
    if c_list[i] == "W":
        temp = check(i + 1)
        if temp != -1:
            c_list[i] = "R"
            c_list[temp] = "W"
            count += 1
        else:
            break
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())

c_list = [s for s in input()]
cr = list(reversed(c_list))
back = N - 1


def check(forward):
    global back
    for i in range(back, -1, -1):
        if back < forward:
            return -1
        if c_list[i] == "R":
            back -= 1
            return back + 1


count = 0
for i, c in enumerate(c_list):
    if c_list[i] == "W":
        temp = check(i + 1)
        if temp != -1:
            c_list[i] = "R"
            c_list[temp] = "W"
            count += 1
        else:
            break
print(count)

Fixed submission:
N = int(input())

c_list = [s for s in input()]
back = N - 1


def check(forward):
    global back
    for i in range(back, -1, -1):
        if i < forward:
            return -1
        if c_list[i] == "R":
            back = i - 1
            return i
    return -1


count = 0
for i, c in enumerate(c_list):
    if c_list[i] == "W":
        temp = check(i + 1)
        if temp != -1:
            c_list[i] = "R"
            c_list[temp] = "W"
            count += 1
        else:
            break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
N, K = map(int, input().split())

A = list(map(int, input().split()))

before = reduce(lambda a, b: a * b, A[:K])
for i in range(0, N - K):
    temp = before // A[i] * A[K + i]
    if temp > before:
        print("Yes")
    else:
        print("No")
    before = temp

Fixed submission:
N, K = map(int, input().split())

A = list(map(int, input().split()))

for i in range(0, N - K):
    if A[i] < A[K + i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
N, K = map(int, input().split())

A = list(map(int, input().split()))

before = reduce(lambda a, b: a * b, A[:K])
for i in range(1, N - K + 1):
    temp = reduce(lambda a, b: a * b, A[i:i + K])
    if temp > before:
        print("Yes")
    else:
        print("No")
    before = temp

Fixed submission:
N, K = map(int, input().split())

A = list(map(int, input().split()))

for i in range(0, N - K):
    if A[i] < A[K + i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

memo = {}


def solve(i, j, k):
    if i == N - 1:
        return j + A[i] * k
    if (i, j, k) in memo:
        return memo[(i, j, k)]
    res = max(solve(i + 1, j, k),
              solve(i + 1, j % A[i], k + j // A[i]),
              solve(i + 1, j + A[i] * k, 0))
    memo[(i, j, k)] = res
    return res


print(solve(0, 1000, 0))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
money = 1000
kabu = 0
temp = A[0]
while count < N:
    if A[count] > temp:
        kabu = money // temp
        money = money % temp
        money += kabu * A[count]
        kabu = 0
    temp = A[count]
    count += 1

print(money)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
i = 0
j = 4
count = 0
if len(S) < 4:
    print(0)
    exit()
while True:
    if int(S[i:j]) % 2019 == 0:
        count += 1
    j += 1
    if j == len(S) + 1:
        if i == len(S) - 3:
            break
        else:
            j = i + 4
            i += 1

print(count)

Fixed submission:
S = input()
mod_list = [0 for i in range(2019)]
mod_list[0] += 1
number = 0
ten_count = 1
for s in S[::-1]:
    number += pow(10, ten_count, 2019) * int(s)
    ten_count += 1
    mod_list[number % 2019] += 1

ans = 0
for i in mod_list:
    if i > 1:
        ans += i * (i - 1) // 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

que = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(K):
    que.pop(0)
    temp = que[0]
    if i == K:
        break
    mod = temp % 10
    if mod == 0:
        que += [temp*10+(mod), temp*10+(mod)+1]
    elif temp % 10 == 9:
        que += [temp*10+(mod)-1, temp*10+(mod)]
    else:
        que += [temp*10+(mod)-1, temp*10+(mod), temp*10+(mod)+1]

print(que[0])


Fixed submission:
K = int(input())

que = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(K):
    temp = que[i]
    if i == K-1:
        print(que[i])
        break
    mod = temp % 10
    if mod == 0:
        que += [temp*10+(mod), temp*10+(mod)+1]
    elif temp % 10 == 9:
        que += [temp*10+(mod)-1, temp*10+(mod)]
    else:
        que += [temp*10+(mod)-1, temp*10+(mod), temp*10+(mod)+1]

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

que = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(K):
    que.pop(0)
    temp = que[0]
    if temp % 10 == 0:
        que.append(temp*10+(temp % 10))
        que.append(temp*10+(temp % 10)+1)
    elif temp % 10 == 9:
        que.append(temp*10+(temp % 10)-1)
        que.append(temp*10+(temp % 10))
    else:
        que.append(temp*10+(temp % 10)-1)
        que.append(temp*10+(temp % 10))
        que.append(temp*10+(temp % 10)+1)


print(que[0])


Fixed submission:
K = int(input())

que = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(K):
    temp = que[i]
    if i == K-1:
        print(que[i])
        break
    mod = temp % 10
    if mod == 0:
        que += [temp*10+(mod), temp*10+(mod)+1]
    elif temp % 10 == 9:
        que += [temp*10+(mod)-1, temp*10+(mod)]
    else:
        que += [temp*10+(mod)-1, temp*10+(mod), temp*10+(mod)+1]
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A_list = list(map(int, input().split(" ")))
C_dic = collections.Counter(A_list)
ans_dic = {}
temp_dic = {}
for i in A_list:
    if i in ans_dic:
        print(ans_dic[i])
    else:
        temp_sum = 0
        for j in C_dic:
            if i == j:
                temp = C_dic[j]-1
                temp = temp*(temp-1)//2
                temp_sum += temp
            else:
                if j in temp_dic:
                    temp_sum += temp_dic[j]
                else:
                    temp = C_dic[j]
                    temp = temp*(temp-1)//2
                    temp_dic[j] = temp
                    temp_sum += temp

        ans_dic[i] = temp_sum
        print(temp_sum)

Fixed submission:
import collections
N = int(input())
A_list = list(map(int, input().split(" ")))
C_dic = collections.Counter(A_list)
ans_dic = {}
sum_cdic = 0
temp_sum = 0
for i in C_dic:
    temp = C_dic[i]
    temp = temp*(temp-1)//2
    temp_sum += temp
sum_cdic = temp_sum

for i in A_list:
    if i in ans_dic:
        print(ans_dic[i])
    else:
        temp_sum = sum_cdic
        temp_sum -= (C_dic[i]*(C_dic[i]-1)//2)
        temp_sum += ((C_dic[i]-1)*(C_dic[i]-2)//2)
        ans_dic[i] = temp_sum
        print(temp_sum)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A_list = list(map(int, input().split(" ")))
C_dic = collections.Counter(A_list)
ans_dic = {}
for i in A_list:
    if i in ans_dic:
        print(ans_dic[i])
    else:
        temp_sum = 0
        for j in C_dic:
            if i == j:
                temp = C_dic[j]-1
            else:
                temp = C_dic[j]
            temp = temp*(temp-1)//2
            temp_sum += temp

        ans_dic[i] = temp_sum
        print(temp_sum)

Fixed submission:
import collections
N = int(input())
A_list = list(map(int, input().split(" ")))
C_dic = collections.Counter(A_list)
ans_dic = {}
sum_cdic = 0
temp_sum = 0
for i in C_dic:
    temp = C_dic[i]
    temp = temp*(temp-1)//2
    temp_sum += temp
sum_cdic = temp_sum

for i in A_list:
    if i in ans_dic:
        print(ans_dic[i])
    else:
        temp_sum = sum_cdic
        temp_sum -= (C_dic[i]*(C_dic[i]-1)//2)
        temp_sum += ((C_dic[i]-1)*(C_dic[i]-2)//2)
        ans_dic[i] = temp_sum
        print(temp_sum)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = input()
N = int(N)
re = False
for i in range(N):
    que = input().split(" ")
    if que[0] == "1":
        if re:
            re = False
        else:
            re = True
    else:
        if re:
            if que[1] == "1":
                S += que[2]
            else:
                S = que[2]+S
        else:
            if que[1] == "1":
                S = que[2]+S
            else:
                S += que[2]
if re:
    S = S[::-1]
print(S)

Fixed submission:
S = input()
N = input()
N = int(N)
re = False
foward = ""
back = ""

for i in range(N):
    que = input().split(" ")
    if que[0] == "1":
        if re:
            re = False
        else:
            re = True
    else:
        if re:
            if que[1] == "1":
                back += que[2]
            else:
                foward += que[2]
        else:
            if que[1] == "1":
                foward += que[2]
            else:
                back += que[2]
S = foward[::-1]+S+back
if re:
    print(S[::-1])
else:
    print(S)

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
q = input()
q = int(q)
reverse_count = 0
for i in range(q):
    que = input().split(" ")
    if que[0] == "1":
        reverse_count += 1
    else:
        if que[1] == "1":
            if reverse_count % 2 == 0:
                a = que[2]+a
            else:
                a += que[2]
        else:
            if reverse_count % 2 == 0:
                a += que[2]
            else:
                a = que[2]+a
if reverse_count % 2 == 1:
    a = a[::-1]
print(a)

Fixed submission:
S = input()
N = input()
N = int(N)
re = False
foward = ""
back = ""

for i in range(N):
    que = input().split(" ")
    if que[0] == "1":
        if re:
            re = False
        else:
            re = True
    else:
        if re:
            if que[1] == "1":
                back += que[2]
            else:
                foward += que[2]
        else:
            if que[1] == "1":
                foward += que[2]
            else:
                back += que[2]
S = foward[::-1]+S+back
if re:
    print(S[::-1])
else:
    print(S)

Buggy python submission (verdict: Time Limit Exceeded):
a = input()
q = input()
q = int(q)
for i in range(q):
    que = input().split(" ")
    if que[0] == "1":
        a = a[::-1]
    else:
        if que[1] == "1":
            a = que[2]+a
        else:
            a += que[2]

print(a)

Fixed submission:
S = input()
N = input()
N = int(N)
re = False
foward = ""
back = ""

for i in range(N):
    que = input().split(" ")
    if que[0] == "1":
        if re:
            re = False
        else:
            re = True
    else:
        if re:
            if que[1] == "1":
                back += que[2]
            else:
                foward += que[2]
        else:
            if que[1] == "1":
                foward += que[2]
            else:
                back += que[2]
S = foward[::-1]+S+back
if re:
    print(S[::-1])
else:
    print(S)
Buggy python submission (verdict: Runtime Error):
x, k, d = map(int, input().split())
if x >= 0:
    if x - k*d >= 0:
        ans = x - k*d
    else:
        pre = x//d
        x -= pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif pre%2 == 1:
            ans = min(abs(x-d), abs(x+d))
elif x <= 0:
    if x + k*d <= 0:
        ans = x + k*d
    else:
        pre = abs(x)//d
        x += pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif pre%2 == 1:
            ans = min(abs(x-d), abs(x+d))
print(ans)

Fixed submission:
x, k, d = map(int, input().split())
if x >= 0:
    if x - k*d >= 0:
        ans = abs(x - k*d)
    else:
        pre = x//d
        x -= pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif k%2 == 1:
            ans = min(abs(x-d), abs(x+d))
elif x <= 0:
    if x + k*d <= 0:
        ans = abs(x + k*d)
    else:
        pre = abs(x)//d
        x += pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif k%2 == 1:
            ans = min(abs(x-d), abs(x+d))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
su = 1
flag = True
for i in range(n):
    su *= a[i]
if su > 10**18:
    flag = False
if flag:
    print(su)
else:
    print(-1)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
su = 1
flag = True
if 0 in a:
    print(0)
else:
    for i in range(n):
        su *= a[i]
        if su > 10**18:
            flag = False
            break
    if flag:
        print(su)
    else:
        print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
l = factorization(n)
dic = []
for i in range(len(l)):
    tmp = l[i][0]
    dic.append(tmp)
    while n >= tmp:
        tmp *= l[i][0]
        if n < tmp:
            break
        dic.append(tmp)
dic.sort()
cnt = 0
while n != 1:
    flag = True
    for i in range(len(dic)):
        if n%dic[i] == 0:
            n //= dic[i]
            cnt += 1
            dic.pop(i)
            flag = False
            break
    if flag:
        break
print(cnt)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
if n == 1:
    print(0)
else:
    l = factorization(n)
    dic = []
    for i in range(len(l)):
        tmp = l[i][0]
        dic.append(tmp)
        while n >= tmp:
            tmp *= l[i][0]
            if n < tmp:
                break
            dic.append(tmp)
    dic.sort()
    cnt = 0
    while n != 1:
        flag = True
        for i in range(len(dic)):
            if n%dic[i] == 0:
                n //= dic[i]
                cnt += 1
                dic.pop(i)
                flag = False
                break
        if flag:
            break
    print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
t = input()
l = len(t)
cnt = 0
ans = ''
for i in range(len(t)):
    if t[i] == 'P' or t[i] == 'D':
        ans += t[i]
    else:
        ans += 'D'
print(ans)

Fixed submission:
t = input()
print(t.replace('?', 'D'))
Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())
ma = -1
for x in range(n, -1, -1):
    tmp = math.floor(a*x/b) - a*math.floor(x/b)
    if ma < tmp:
        ma = tmp
print(ma)

Fixed submission:
import math
a, b, n = map(int, input().split())
def f(x):
    return math.floor(a*x/b) - a*math.floor(x/b)
print(f(min(b-1, n)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
cnt = 0
for i in range(n):
    s = input()
    if s not in l:
        cnt += 1
        l.append(s)
print(cnt)

Fixed submission:
n = int(input())
l = {}
for i in range(n):
    s = input()
    l[s] = 1
print(len(l))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
q = [1, 2, 3, 4, 5, 6, 7, 8, 9]
ans = 0
for i in range(k):
    ans = q.pop(0)
    x = ans
    if x%10 != 0:
        q.append(10*x + (x%10) - 1)
    q.append(10*x + (x%10))
    if x%10 != 9:
        q.append(10*x + (x%10) + 1)
print(ans)

Fixed submission:
k = int(input())
l = []
for i in range(1, 10):
    l.append(i)
judge = l
for d in range(1, 10):
    tmp = []
    for i in range(len(judge)):
        val = judge[i]
        for j in range(-1, 2):
            add = val%10 + j
            if add >= 0 and add <= 9:
                tmp.append(val*10 + add)
    for i in range(len(tmp)):
        l.append(tmp[i])
    judge = tmp
print(l[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
han = False
for i in range(q):
    x = list(input())
    if len(x) == 1:
        if han:
            han = False
        else:
            han = True
        #s.reverse()
    else:
        if han:
            if x[2] == "1":
                s.append(x[4])
            else:
                s.insert(0, x[4])
        else:
            if x[2] == "1":
                s.insert(0, x[4])
            else:
                s.append(x[4])
if han:
    s.reverse()
print("".join(s))

Fixed submission:
s = list(input())
q = int(input())
left = []
right = []
rev = False
for i in range(q):
    x = list(input())
    if len(x) == 1:
        rev = not rev
        #s.reverse()
    else:
        if (x[2] == "1" and not rev) or (x[2] == "2" and rev):
            left.append(x[4])
        else:
            right.append(x[4])
ans = "".join(left[::-1]) + "".join(s) + "".join(right)
if rev:
    print(ans[::-1])
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
for i in range(q):
    x = list(input())
    if len(x) == 1:
        s.reverse()
    else:
        if x[2] == "1":
            s.insert(0, x[4])
        else:
            s.append(x[4])
print("".join(s))

Fixed submission:
s = list(input())
q = int(input())
left = []
right = []
rev = False
for i in range(q):
    x = list(input())
    if len(x) == 1:
        rev = not rev
        #s.reverse()
    else:
        if (x[2] == "1" and not rev) or (x[2] == "2" and rev):
            left.append(x[4])
        else:
            right.append(x[4])
ans = "".join(left[::-1]) + "".join(s) + "".join(right)
if rev:
    print(ans[::-1])
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a == b:
    if b != c:
    print("Yes")
elif b == c:
    if c != a:
    print("Yes")
elif c == a:
    if a != b:
        print("Yes")
else:
    print("No")

Fixed submission:
a, b, c = map(int, input().split())
if a == b and b != c:
        print("Yes")
elif b == c and c != a:
        print("Yes")
elif c == a and a != b:
        print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a == b:
    if a != c:
    print("Yes")
elif b == c:
    if b != a:
    print("Yes")
elif a == c:
    if a != b:
        print("Yes")
else:
    print("No")

Fixed submission:
a, b, c = map(int, input().split())
if a == b and b != c:
        print("Yes")
elif b == c and c != a:
        print("Yes")
elif c == a and a != b:
        print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
#素因数分解
def factorization(n):
    arr = [[1, 1]]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a, b = map(int, input().split())
g = math.gcd(a, b)
l = factorization(g)
print(len(l))

Fixed submission:
def factorization(n):
    arr = [[1, 1]]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
a, b = map(int, input().split())
g = gcd(a, b)
l = factorization(g)
print(len(l))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))

    return get_counter(first_word) == get_counter(second_word)

n = int(input())
s = []
for i in range(n):
    l = input()
    s.append(l)
cnt = 0 
for i in range(n-1):
    for j in range(i+1, n):
        if verify_anagrams(s[i], s[j]) == True:
            cnt += 1
print(cnt)



Fixed submission:
from collections import Counter
n=int(input())
s = []
for i in range(n):
    t = list(input())
    t.sort()
    s.append(''.join(t))
c = Counter(s)
sum = 0
for i in c.values():
    sum += i*(i-1)//2
print(sum)

"""
n = int(input())
dic = {}
for i in range(n):
    s = list(input())
    s.sort()
    t = "".join(s)
    if t in dic.keys():
        dic[t] += dic[t] + 1
    elif t not in dic.keys():
        dic[t] = 0
print(sum(dic.values()))
"""
Buggy python submission (verdict: Runtime Error):
n = int(input())
if 1 <= n and n <= 9:
    pint(n)
elif 10 <= n and n <= 99:
    print(9)
elif 100 <= n and n <= 999:
    print(9+n-99)
elif 1000 <= n and n <= 9999:
    print(9+999-99)
elif 10000 <= n and n <= 99999:
    print(9+999-99+n-9999)
elif 100000 <= n and n <= 999999:
    print(9+999-99+999999-99999)

Fixed submission:
n = int(input())
if 1 <= n and n <= 9:
    print(n)
elif 10 <= n and n <= 99:
    print(9)
elif 100 <= n and n <= 999:
    print(9+n-99)
elif 1000 <= n and n <= 9999:
    print(9+999-99)
elif 10000 <= n and n <= 99999:
    print(9+999-99+n-9999)
elif 100000 <= n and n <= 999999:
    print(9+999-99+99999-9999)