Harryxun/stf_run huggingface dataset:
word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif (i == (end-1)):
		word = word.replace('?', "D", 1)   
	elif (word[i-1] == 'P'):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
    else:
      word = word.replace('?', "D", 1)
	start = i + 1
print(word)

### FIXED CODE ###

word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif (i == (end-1)):
		word = word.replace('?', "D", 1)   
	elif (word[i-1] == 'P'):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
	else:
		word = word.replace('?', "D", 1)
	start = i + 1
print(word)
s = [i for i in input()]

for i in s:
    if i == 'B':
        s.remove(i)
        s.remove(tmp)  
    tmp = i

if s[0] == 'B':
    s.remove('B')
print("".join(s))

### FIXED CODE ###


n = input()
 
res = []
 
for char in n:
    if char == '0':
        res.append(char)
    elif char == '1':
        res.append(char)
    elif char == 'B':
        if len(res) > 0:
            res.pop()
 
print(''.join(res))
N, K = map(int, input().split())
P = list(map(lambda s: int(s) - 1, input().split()))
C = list(map(int, input().split()))

visited = [False] * N
ans = []
for i in range(N):
    if visited[i]:
        continue
    visited[i] = True
    S = [C[i]]
    p = P[i]
    while p != i:
        visited[p] = True
        S.append(C[p])
        p = P[p]
    s = sum(S)
    n = len(S)
    SS = S + S
    if s <= 0 or K < n:
        a = max(sum(SS[j:j + c + 1])
                for j in range(N) for c in range(min(K, n)))
    else:
        M = max(sum(SS[j:j + c + 1]) for j in range(N) for c in range(K % n))
        a = s * (K // n) + M
    ans.append(a)

print(max(ans))


### FIXED CODE ###

N, K = map(int, input().split())
P = list(map(lambda s: int(s) - 1, input().split()))
C = list(map(int, input().split()))

ans = -1_000_000_000
for i in range(N):
    S = [C[i]]
    p = P[i]
    while p != i:
        S.append(C[p])
        p = P[p]
    s = sum(S)
    n = len(S)
    acc = 0
    for i in range(min(n, K + 2)):
        acc += S[i]
        a = acc
        if s > 0:
            a += s * ((K - (i + 1)) // n)
        ans = max(a, ans)

print(ans)
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:break
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if i+j+k==x:a+=1
    print(a)


### FIXED CODE ###

while True:
    n,x=map(int,input().split())
    a=0
    if n==0 and x==0:break
    for i in range(1,n+1):
        for j in range(1,i):
            for k in range(1,j):
                if i+j+k==x:a+=1
    print(a)
dishes_1 = [int(input()) for i in range(5)]
dishes_2 = [i % 10 for i in dishes_1]
dishes_sort = []

min_time = 0

for i in range (5):
    if dishes_2[i] == 0:
       dishes_sort.append(dishes_1[i])

for i in range (9, 1, -1):
    for j in range (5):
        if dishes_2[j] == i:
            dishes_sort.append(dishes_1[j])

for i in range (4):
    for j in range (9):
        if dishes_sort[i] % 10 == 0:
           break
        else:
            dishes_sort[i] += 1
            
print (sum(dishes_sort))

### FIXED CODE ###

dishes_1 = [int(input()) for i in range(5)]
dishes_2 = [i % 10 for i in dishes_1]
dishes_sort = []

min_time = 0

for i in range (5):
    if dishes_2[i] == 0:
       dishes_sort.append(dishes_1[i])

for i in range (9, 0, -1):
    for j in range (5):
        if dishes_2[j] == i:
            dishes_sort.append(dishes_1[j])

for i in range (4):
    for j in range (9):
        if dishes_sort[i] % 10 == 0:
           break
        else:
            dishes_sort[i] += 1
            
print (sum(dishes_sort))
def partition(a, p, r):
    x = a[r]
    i = p-1

    for j in range(p, r):
        if a[j] <= x:
            i += 1
            tmp = a[i]
            a[i] = a[j]
            a[j] = tmp

    tmp = a[i+1]
    a[i+1] = a[r]
    a[r] = tmp
    return a, i+1


n = int(input())
A = list(map(int, input().split()))
ans, idx = partition(A, 0, n-1)
print(*ans[:idx], [ans[idx]], *ans[idx+1:])

### FIXED CODE ###

def partition(p, r):
    x = a[r]
    i = p-1

    for j in range(p, r):
        if a[j] <= x:
            i += 1
            a[i], a[j] = a[j], a[i]

    a[i+1], a[r] = a[r], a[i+1]
    return i+1


n = int(input())
a = list(map(int, input().split()))
idx = partition(0, n-1)
a[idx] = [a[idx]]
print(*a)
S = list(input())
T = list(input())
s = len(S)
t = len(T)
OK = False
P = 0
for i in range(s - t + 1):
    if S[i] != T[0] and S[i] != '?':
        continue
    for j in range(1, t):
        if S[i + j] != T[j] and S[i + j] != '?':
            OK = False
            break
        if j == t - 1:
            OK = True
            P = i
for k in range(t):
    S[P + k] = T[k]
for i in range(s):
    if S[i] == '?':
        S[i] = 'a'
if OK:
    [print(S[i], end='') for i in range(s)]
    print('')
else:
    print('UNRESTORABLE')

### FIXED CODE ###

import sys
S = input()
T = input()
s = len(S)
t = len(T)
if s < t:
    print('UNRESTORABLE')
    sys.exit()

for i in range(s - t, -1, -1):
    OK = True
    for j in range(t):
        if S[i + j] != T[j] and S[i + j] != '?':
            OK = False
    if OK:
        for j in range(t):
            SS = S[:i] + T + S[i + j + 1:]
            SS = SS.replace('?', 'a')
        print(SS)
        sys.exit()

print('UNRESTORABLE')
import math
A,B,C,D=map(int,input().split())
CD=(C*D)//(math.gcd(C,D))
A=A-1
num_B=B-B//C-B//D+B//CD
num_A=A-A//C-A//D+A//CD
print(int(num_B-num_A))

### FIXED CODE ###

import fractions
A,B,C,D=map(int,input().split())
CD=(C*D)//(fractions.gcd(C,D))
A=A-1
num_B=B-B//C-B//D+B//CD
num_A=A-A//C-A//D+A//CD
print(int(num_B-num_A))
n, k = map(int, input().split())
n = list(map(str, range(1, n+1)))

for i in range(k):
    _ = input()
    a = input().split()
    for ai in a:
        n.remove(ai)
print(len(n))

### FIXED CODE ###

n, k = map(int, input().split())
n = list(map(str, range(1, n+1)))

for i in range(k):
    _ = input()
    a = input().split()
    for ai in a:
        for ni in n:
            if ai == ni:
                n.remove(ai)
print(len(n))
a, b, c, d = list(map(int, input().split()))
l = a+b
r = c+d
if l > r: print('Left')
elif: l < r: print('Right')
else: print('Balanced')

### FIXED CODE ###

a, b, c, d = list(map(int, input().split()))
l = a+b
r = c+d
if l > r: print('Left')
elif l < r: print('Right')
else: print('Balanced')
from math import gcd
a,b = map(int,input().split())
def lcm(a,b):
    return a*b//gcd(a,b)
print(lcm(a,b))

### FIXED CODE ###

from fractions import gcd
a,b = map(int,input().split())
def lcm(x,y):
    return x*y//gcd(x,y)
print(lcm(a,b))
x,y=map(int,input().split())

def main():
    if 0<=(y/2 -x)<=x:
        if y==0 or x==0:
            return 'No'
        if (y/2 -x)%1==0:
            return('Yes')
        else:
            return('No')
    else:
        return('No')
print(main())



### FIXED CODE ###

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

for i in range(5):
    if arr[i]==0:
        print(i+1)
N = int(input())
A = list(map(int,input().split()))
b = sorted([a-i for i,a in enumerate(A,1)])

minus = 0
plus = 0
for c in b:
    if c <0:
        minus +=1
    elif c >0:
        plus +=1

m1 = b[N//2]
m2 = b[N//2+1]
out = min(sum([abs(c-m1) for c in b]),sum([abs(c-m2) for c in b]))
print(out)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
b = sorted([a-i for i,a in enumerate(A,1)])

minus = 0
plus = 0
for c in b:
    if c <0:
        minus +=1
    elif c >0:
        plus +=1

m1 = b[N//2]
m2 = b[0] if N==1 else b[N//2+1]
out = min(sum([abs(c-m1) for c in b]),sum([abs(c-m2) for c in b]))
print(out)
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        if N >= C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

### FIXED CODE ###

A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)
import math
N = input()

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

ans = float("inf")

for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

### FIXED CODE ###

print(input().count("1"))
a,b,c,d=map(int,input().split())
if a*b=c*d:
  print(a*b)
elif a*b>c*d:
  print(a*b)
else:
  print(c*d)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
if a*b==c*d:
  print(a*b)
elif a*b>c*d:
  print(a*b)
else:
  print(c*d)
# ABC075B - Minesweeper
def check_neighbors(i: int, j: int) -> int:
    # count the number of landmines adjacent to S[i][j]
    ret = 0
    for x, y in neighbors:
        a, b = i + x, j + y
        if 0 <= a < H and 0 <= b < W:
            ret += 1 if S[a][b] == "#" else 0
    return ret


def main():
    global S, neighbors
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    neighbors = [(-1, -1), (-1, 0), (-1, 1), (0, -1)]
    neighbors += [(0, 1), (1, -1), (1, 0), (1, 1)]
    A = [""] * H
    for i, s in enumerate(S):
        for j, a in enumerate(s):
            if a == "#":
                A[i] += "#"
            else:
                cnt = check_neighbors(i, j)
                A[i] += str(cnt)
    print(*A, sep="\n")


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC075B - Minesweeper
h, w = list(map(int, input().rstrip().split()))
lst = [list(input().rstrip()) for _ in range(h)]
emp_lst = ["."] * (w + 2)

for i in lst:
    i.append(".")
    i.insert(0, ".")

lst.append(emp_lst)
lst.insert(0, emp_lst)

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if lst[i][j] == ".":
            count = 0
            if lst[i - 1][j - 1] == "#":
                count += 1
            if lst[i - 1][j] == "#":
                count += 1
            if lst[i - 1][j + 1] == "#":
                count += 1
            if lst[i][j - 1] == "#":
                count += 1
            if lst[i][j + 1] == "#":
                count += 1
            if lst[i + 1][j - 1] == "#":
                count += 1
            if lst[i + 1][j] == "#":
                count += 1
            if lst[i + 1][j + 1] == "#":
                count += 1
            lst[i][j] = count

for i in range(1, h + 1):
    for j in range(1, w + 1):
        print(lst[i][j], end="")
    print()
N, X = map(int, input().split())
x = list(map(int, input().split()))

import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

x.sort()
import numpy as np
x = np.array(x)
x -= X
print(gcd(*x))

### FIXED CODE ###

N, X = map(int, input().split())
x = list(map(int, input().split()))

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

x.sort()
import numpy as np
x = np.array(x)
x -= X
print(abs(gcd(*x)))
c=[1]*(10**9)
a=[]
n=int(input())
for i in range(n):
    ai=int(input())-1
    c[ai]=1-c[ai]
    a.append(ai)
    
icnt=0
for i in range(n):
  if c[a[i]]==0:
      icnt=icnt+1
      
print(icnt)


### FIXED CODE ###

dicc=dict()

n=int(input())
for i in range(n):
    ai=input()
    if ai in dicc:
        dicc[ai]=1-dicc[ai]
    else:
        dicc[ai]=1
        
icnt=0    
for i in dicc.values():
    icnt=icnt+i
      
print(icnt)
d,n = map(int,input().split())
if n <= 99:
  print(n * (100 ** d))
elif n = 100:
  print(101 * (100 ** d))

### FIXED CODE ###

d,n = map(int,input().split())
s = n * (100**d)
s1 = 101 * (100**d)
if n <= 99:
  print(s)
else:
  print(s1)
a=input()
b=input()

print(a*b,2a+2b)


### FIXED CODE ###

a,b=map(int,input().split())
print(a*b,2*(a+b))
c = [[map(int,input().split())] for i in range(3)]
a1,a2,a3,b1,b2,b3 = 0,c[1][0]-c[0][1],\
c[2][0]-c[0][2],c[0][0],c[0][1],c[0][2]

if c[1][1]==a2+b2 and c[1][2]==a2+b3 and\
c[2][1]==a3+b2 and c[2][2]==a3+b3:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

c = [list(map(int,input().split())) for i in range(3)]
a1,a2,a3,b1,b2,b3 = 0,c[1][0]-c[0][0],\
c[2][0]-c[0][0],c[0][0],c[0][1],c[0][2]

if c[1][1]==a2+b2 and c[1][2]==a2+b3 and\
c[2][1]==a3+b2 and c[2][2]==a3+b3:
    print('Yes')
else:
    print('No')
n,q,k = map(int,input().split())
attend = [k-q for i in range(n)]
a = 0
for i in range(q):
    a = int(input())
    attend[a-1]+= 1
for i in range(n):
    if (attend[1] <= 0):
        print("No")
    else:
        print("Yes")

### FIXED CODE ###

n,k,q = map(int,input().split())
attend = [k-q for i in range(n)]
a = 0
for i in range(q):
    a = int(input())
    attend[a-1]+= 1
for i in range(n):
    if (attend[i] <= 0):
        print("No")
    else:
        print("Yes")
N, K, S = map(int, input())

ans = [S]*K
ans += [S+1]*(N - K)

print(ans)

### FIXED CODE ###

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

ans = [S]*K
if S == 10**9:
    #最大値の時に制限の値を超えないように
    ans += [1]*(N - K)   
else:
    ans += [S+1]*(N - K)
ans = list(map(str, ans))

print(" ".join(ans))
from collections import defaultdict,Counter
n = int(input())
al = list(map(int, input().split()))

c_al  = Counter(al)

if n % 2 == 0 and 0 not in c_al.values():
    print(int(2**(n/2)))
elif n % 2 != 0 and c_al[0] == 1:
    print(int(2 ** ((n // 2))))

### FIXED CODE ###

from collections import Counter

n = int(input())
al = list(map(int, input().split()))

c_al = Counter(al)

if n % 2 == 0:
    for k,v in c_al.items():
        if v != 2:
            print(0)
            exit()
    print(pow(2, n // 2, 10 ** 9 + 7))

elif n % 2 != 0:
    for k, v in c_al.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        elif v != 2:
            print(0)
            exit()
    print(pow(2, n // 2, 10 ** 9 + 7))
l = map(int, input().split())
 
print(int(l[0] + l[1] / 2))

### FIXED CODE ###

x, y = map(int, input().split())
print(x + y//2)
import math
N = int(input())
print(factorial.(N)%(10**9+7))

### FIXED CODE ###

import math

N = int(input())
print(math.factorial(N) % (10**9+7))
import math

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

A_row = math.ceil((A-1)/50)
if A_row == 0:
    A_row = 1
A_row_full = (A-1)//50
B_row = math.ceil((B-1)/50)
if B_row == 0:
    B_row = 1
B_row_full = (B-1)//50

print("100 ", (A_row+B_row)*2)

A_mod = (A-1)%50
B_mod = (B-1)%50

if A_row == A_row_full:
    A_add = ''
else:
    A_add = '.#'

if B_row == B_row_full:
    B_add = ''
else:
    B_add = '.#'
    

for i in range(50):
    print('.#'*A_row_full + (A_add if i < A_mod else '##') + '.#'*B_row_full + (B_add if i < B_mod else '..'))
    print('##'*A_row + '..'*B_row)


### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())

densha = min(A,B)
bus = min(C,D)

print(densha+bus)
n,a,b=map(int,input().split())
print(min(a*t,b))

### FIXED CODE ###

n,a,b=map(int,input().split())
print(min(a*n,b))
import math
R = input()
a = 2*R*math.pi
print(a)

### FIXED CODE ###

import math
R = int(input())
a = 2*math.pi*R
print(a)
n, k = map(int, input().split())
ans = n - k
if k == 1 or n == 1:
    print(1)
    quit()
if n % k == 0:
    print(0)
    quit()
if n < k:
    print(n)
    quit()

print(min(ans, k - n%k))


### FIXED CODE ###

x, y, z = map(int, input().split())
print("{} {} {}".format(z,x,y))
s = input()
t = input()

if s = t[:-1]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = input()
t = input()

if s+t[-1] == t:
  print('Yes')
else:
  print('No')
N, M = map(int,input().split())
array = list(map(int,input().split()))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
for j in range(M):
  array.sort()
  i = 0
  while (array[i] < convert[j][1]) & (i < convert[j][0]):
    array[i] = convert[j][1]
    i += 1
print(sum(array))

### FIXED CODE ###

N, M = map(int,input().split())
array = sorted(list(map(int,input().split())))
convert = [list(map(int,input().split())) for _ in range(M)]
convert.sort(key=lambda x: x[1])
convert.reverse()
i = 0
for j in range(M):
  #array.sort()
  start = 0
  while (array[i] < convert[j][1]) & (start < convert[j][0]):
    array[i] = convert[j][1]
    #print(array)
    i += 1
    start += 1
    if i == N:
      break
  if i == N:
    break

print(sum(array))
import sys
sys.setrecursionlimit(1000000)
n, q = map(int, input().split())
edge = [set() for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].add(b-1)
    edge[b-1].add(a-1)

cost = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    cost[p-1] += x

ans = [0] * n
def dfs(v,p,value): #p: parent of v
    value += cost[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)
# def dfs(cur, c, root):
    # # print(cur, c, root)
    # ans[cur] = c
    # for nex in edge[cur]:
        # if nex != root:
            # dfs(nex, c + cost[nex], cur)

dfs(0, -1, 0)
print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

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

connect = [set() for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

ans = [0] * n
def dfs(me, parent, cum):
    cum += counter[me]
    ans[me] = cum
    for child in connect[me]:
        if child != parent:
            dfs(child, me, cum)

dfs(0, -1, 0)

print(*ans)
x,a,b=map(int,input().split())
print((x-a)%b)

### FIXED CODE ###

x=int(input())
a=int(input())
b=int(input())
print((x-a)%b)
import math


def main():
    A, B, C, D = map(int, input().split())

    def num_of_multiples(st, ed, m):
        a = st % m
        a0 = st + (m - a)
        if a0 > ed:
            return 0
        if a == 0:
            a0 = st
        b = ed % m
        b0 = ed - b
        num = (b0 - a0)
        if num % m != 0:
            raise Exception()
        return (b0 - a0) // m + 1
    
    nc = num_of_multiples(A, B, C)
    nd = num_of_multiples(A, B, D)
    ncd = num_of_multiples(A, B, C * D // math.gcd(C, D))
    print(B - A + 1 - (nc + nd - ncd))


main()

### FIXED CODE ###

import fractions

def main():
    A, B, C, D = map(int, input().split())

    def num_of_multiples(st, ed, m):
        a = st % m
        a0 = st + (m - a)
        if a == 0:
            a0 = st
        if a0 > ed:
            return 0
        b = ed % m
        b0 = ed - b
        num = (b0 - a0)
        if num % m != 0:
            raise Exception()
        return (b0 - a0) // m + 1
    
    nc = num_of_multiples(A, B, C)
    nd = num_of_multiples(A, B, D)
    ncd = num_of_multiples(A, B, C * D // fractions.gcd(C, D))
    print(B - A + 1 - (nc + nd - ncd))


main()
a,b,c=(int(i) for i in input().split())
while i<9:
  i=i+1
  c=a*c-b
  print(c)


### FIXED CODE ###

a,b=(int(i) for i in input().split())
if a<=5:
  print(0)
elif 5<a<=12:
  print(b//2)
else:
  print(b)
import math
A,B,H,M = map(int,input().split())
A2 = A**2
B2 = B**2
pi = round(math.pi,20)
a = 30*H + 0.5*M
b = M*6
F  = 0
if abs(a-b) == 180:
    F = 1
    print(A+B)
elif abs(a-b) ==0:
    F = 1
    print(abs(A-B))
elif abs(a-b) < 180 and 0 < abs(A-B):
    angle = round(math.cos(math.radians(abs(a-b))),20)
elif 180 < abs(a-b):
    angle = round(math.cos(math.radians(abs(360-a-b))),20)

if F == 0:
    ab_angle = round(2*A*B*angle,20)
    print(round((A2 + B2 - ab_angle)**0.5,20))

### FIXED CODE ###

import math
A,B,H,M = map(int,input().split())
a = 30*H + 0.5*M
b = M*6
if abs(a-b) < 180:
    ab = abs(a-b)
else:
    ab = 360 - abs(a-b)
ab1 = round(math.cos(math.radians(ab)),20)
ans = round(math.sqrt(A**2 + B**2 - 2 * A* B*ab1),20)
print(round(ans,20))
sec = int(raw_input())
H = 3600
M = 60

h = sec / H
sec = sec % H
m = sec / M
s = sec % M

print h+":"+m+":"+s

### FIXED CODE ###

sec = int(raw_input())
H = 3600
M = 60

h = sec / H
sec = sec % H
m = sec / M
s = sec % M

print str(h)+":"+str(m)+":"+str(s)
# import module
import sys
import math
import numpy as np

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

x = int(N / (A+B)) 
y = N % (A+B)

if y > A:
    print(x*A+ A)
else
    print(x*A + y )



### FIXED CODE ###

# import module
import sys
import math
import numpy as np

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

x = int(N / (A+B)) 
y = N % (A+B)

if y > A:
    print(x*A+ A)
else:
    print(x*A + y )
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []

s = sum(t)

for i in range(m):
    p.append(input().split())

for i in range(m):
    print(s-t[i]+int(p[i][1]))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s+x-a[p-1])
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[i] > 10**5:
        ans += 1
        del a[i]
        
import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
ans = 0
idx = []
for i,x in enumerate(a):
    if x > 10**5:
        ans += 1
        idx += [i]
for i in reversed(idx):
    del a[i]

import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)
from collections import defaultdict
S = input()

T = [s if s != "?" else "0" for s in S]
T = int(''.join(T))
SS = T % 13

c = {}
for i in range(len(S)):
    if S[len(S) - i - 1] != "?":
        continue
    tc = defaultdict(lambda: 0)
    for j in range(0, 10):
        t = j * 10 ** i
        tc[t % 13] += 1
    c[i] = tc

dp = [{SS: 1}]
for k, v in c.items():
    tdp = defaultdict(lambda: 0)
    for r, c in v.items():
        for _r, _v in dp[-1].items():
            tdp[(_r + r) % 13] += _v * c
    dp.append(tdp)

ans = dp[-1][5]
print(ans % (10**9 + 7))

### FIXED CODE ###

S = input()
con = 10**9 + 7

T = [s if s != "?" else "0" for s in S]
T = int(''.join(T))
SS = T % 13

def get_mod(S):
    c = {}
    iii = 1
    for i in range(len(S)):
        if S[len(S) - i - 1] != "?":
            iii *= 10
            iii %= 13
            continue
        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)}
        iii *= 10
        iii %= 13
    return c
c = get_mod(S)

def get_tdp(pdp):
    tdp = {i: 0 for i in range(13)}
    for r in v.keys():
        for _r, _v in pdp.items():
            tdp[(_r + r) % 13] += _v
    for i in range(13):
        tdp[i] %= con
    return tdp

pdp = {i: 0 for i in range(13)}
pdp[SS] += 1
for k, v in c.items():
    pdp = get_tdp(pdp)

ans = pdp[5]
print(ans)