peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,m=map(int, input().split())
s=[list(map(int, input().split())) for i in range(m)]
x=max(a for a,b in s)
dp=[0]*(n+x)
for i in range(0,n+x):
  if i>0:
    dp[i]=min(dp[i-a]+b for a,b in s)
print(min(dp[n:]))
# Judge status: Accepted
def fact(a):
    b = 1
    for i in range(1,a+1):
        b = (b*i)%inf
    return b
inf = 10**9+7
N, M = map(int,input().split())
if abs(N-M) == 1:
    ans = fact(N)*fact(M)%inf
elif abs(N-M) == 0:
    ans = fact(N)*fact(M)*2%inf
else: ans = 0
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
z = 'APPROVED'
for i in a:
    if i%2 == 0:
        if i%3 != 0 and i%5 != 0:
            z = 'DENIED'
            break
print(z)
# Judge status: Accepted
n=int(input())
s=input()
x=0
ans=0
for i in range(n):
    if s[i]=="I":
        x+=1
    elif s[i]=="D":
        x-=1
    if ans<x:
        ans=x
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())
if B >= 2:
    ans = 1
    tap = A
    while True:
        if tap >= B:
            break
        ans += 1
        tap += A-1
else:
    ans = 0
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
if c-a-b<=0:
  print("No")
  exit()
if a*b*4<((c-a-b)**2):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
A, B = map(int, input().split());print(sum(str(i)==str(i)[::-1]for i in range(A,B+1)))
# Judge status: Accepted
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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

    if N == 1:
        if A != B:
            print(0)
        else:
            print(1)
    elif N == 2:
        print(1)
    else:
        if A <= B:
            print(B * (N-1) + A - (A * (N-1) + B) + 1)
        else:
            print(0)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())

if N % 2 == 1:
    print(0)
elif N < 2:
    print(0)
else:
    ans = 0
    d = 10
    while N // d > 0:
        ans += N // d
        d *= 5
    print(ans)
# Judge status: Accepted
x = int(input())
for i in range(-(~x//100)):
    if i*100 <= x <= i*105:
        print(1)
        break
else:
    print(0)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1 if not A[0] else -1)
    exit()

if A[0] and N > 1:
    print(-1)
    exit()

# 根の数
node = 1
root = 0

s = sum(A)

for i in range(len(A) - 1):
    node = min(s, node * 2) - A[i + 1]
    
    if node < 0:
        print(-1)
        exit()
    
    s -= A[i + 1]
    root += node

print(root + sum(A) + 1 if not node else -1)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
if n%2==0:
    B = A[1::2][::-1] + A[::2]
    print(*B)
else:
    B = A[::2][::-1] + A[1::2]
    print(*B)
# Judge status: Wrong Answer
from fractions import gcd

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    half_a = list(map(lambda x: x // 2, A))

    def lcm(x, y):
        return x * y // gcd(x, y)
        
    b = half_a[0]
    for c in half_a[1:]:
        l = lcm(b, c)
        if not ((l // b) % 2) and ((l // c) % 2):
            print(0)
            exit()
        b = l
        
    print((M + b) // (b * 2))
    
main()
# Judge status: Wrong Answer
NXT= [int(i) for i in input().split(' ')]
i=NXT[0]
count=0
while i>=0: 
    i -= NXT[1];count +=1
print(int(NXT[2]*count))
# Judge status: Accepted
n, y = map(int, input().split())
x = 0
for i in range(n + 1):
  for j in range(n + 1 - i):
    if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
      print(i, j, (n - i - j))
      x = 1
      break
  if x == 1:
    break
else:
  print(-1, -1, -1)
# Judge status: Accepted
N = int(input())

num_array = [[0]*2 for i in range(N)]
for i in range(N):
    x, l = map(int, input().split())
    small = x-l
    if small <= 0:
        small = 0
    big = x+l

    num_array[i][1] = small
    num_array[i][0] = big

num_array.sort()

tmp_r = -(10**18)
count = 0
for r, l in num_array:
    if tmp_r > l:
        continue
    count += 1
    tmp_r = r

print(count)
# Judge status: Accepted
N, K = map(int, input().split())
t = 0
i = 1
while(i < K):
    t += 1
    i *= 2
under = 2**t

p = 0
for i in range(1, N+1):
    c = 0
    while(i < K):
        c += 1
        i *= 2
    p += 2**(t-c)
print(p/((2**t)*N))
# Judge status: Accepted
from collections import Counter
N=int(input())
a=[]
for i in range(N):
  a.append(input())
c = Counter(a)

print("AC x "+str(a.count("AC")))
print("WA x "+str(a.count("WA")))
print("TLE x "+str(a.count("TLE")))
print("RE x "+str(a.count("RE")))
# Judge status: Accepted
N = int(input())
*A, = map(int, input().split())


d = {}


for i in range(N):
    if A[i] in d:
        d[A[i]] += 1
        continue
    d[A[i]] = 1

d = sorted(d.items(), reverse=True)

a = []

for key, data in d:
    if data>=4:
        a.append(key)
        a.append(key)
    elif data>=2:
        a.append(key)

if len(a)>=2:
    print(a[0]*a[1])
else:
    print(0)
# Judge status: Accepted
import sys

def main(lines):
  N, K = map(int, lines[0].split())
  a = list(map(int, lines[1].split()))
  ans = 1000000000000
  for i in range(N):
    if i + K - 1 >= N:
      break
    b = a[i]
    c = a[i + K - 1]
    if b < 0 and c >= 0:
      ans = min(ans, max(abs(b), abs(c)) + 2*min(abs(b), abs(c)))
    else:
      ans = min(ans, max(abs(b), abs(c)))
  print(ans)


if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)
# Judge status: Accepted
k = int(input())

if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  num = 7
  ans = 1
  while num % k != 0:
    num *= 10
    num += 7
    ans += 1
    num %= k
  print(ans)
# Judge status: Accepted
n, m = map(int, input().split())

t = [-1] * n
for _ in range(m):
   s, c = map(int, input().split())
   s -= 1

   if (t[s] != -1 and t[s] != c):
      print(-1)
      exit()
   t[s] = c

if (n > 1):
   if (t[0] == 0):
      print(-1)
      exit()

   if (t[0] == -1):
      t[0] = 1

   for i in range(1, n):
      if (t[i] == -1):
         t[i] = 0

else:
   if (t[0] == -1):
      t[0] = 0

print(''.join(map(str, t)))
# Judge status: Accepted
N,M = map(int,input().split())
A = list(map(int,input().split()))
su = sum(A)

a = 0
for i in range(N):
    if A[i] >= su/4/M :
        a += 1

print(["No","Yes"][a>=M])
# Judge status: Accepted
N = int(input())
print((N-1)*(N) // 2)
# Judge status: Accepted
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
  if word in dictionary:
    dictionary[word]+=1
  else:
    dictionary[word]=1
maximum=max(dictionary.values())
for key, value in sorted(dictionary.items()):
  if value==maximum:
    print(key)
# Judge status: Wrong Answer
n = int(input())
cnt = [False]*n

for i in range(n):
    x,y = map(int, input().split())
    cnt[i] = x == y

ans = 'No'

for i in range(n-3):
    if cnt[i] and cnt[i+1] and cnt[i+2]:
        ans = 'Yes'

print(ans)
# Judge status: Wrong Answer
s = input()

if s[-1] == "s":
    print(s[:-1] + "es")

else:
    print(s + "s")
# Judge status: Accepted
s = input()
MOD = 2019
r = [0]*MOD
r[0] = 1
z = 0
t = 0
for i in reversed(s):
    z = int(i) * pow(10,t,MOD) + z
    z %= MOD
    r[z] += 1
    t += 1
print(sum(i*(i-1)//2 for i in r))
# Judge status: Accepted
# -*- coding: <encoding name> -*-

a, b, c = map(int, input().split())
print(a * b // 2)
# Judge status: Accepted
s = input()
ok = False

if s.startswith('keyence'):
    ok = True
if s.startswith('k') and s.endswith('eyence'):
    ok = True
if s.startswith('ke') and s.endswith('yence'):
    ok = True
if s.startswith('key') and s.endswith('ence'):
    ok = True
if s.startswith('keye') and s.endswith('nce'):
    ok = True
if s.startswith('keyen') and s.endswith('ce'):
    ok = True
if s.startswith('keyenc') and s.endswith('e'):
    ok = True
if s.endswith('keyence'):
    ok = True

if ok:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
from sys import stdin,setrecursionlimit
import string
setrecursionlimit(10 ** 7)
n = int(stdin.readline().rstrip())
print(n*(n-1)//2)
# Judge status: Wrong Answer
n,m=map(int,input().split())
cnt_s=n
cnt_c=m
ans=0
if cnt_s>cnt_c:
  ans=cnt_c//2
  print(ans)
elif cnt_s<=cnt_c:
  ans+=n
  cnt_c-=2*n
  ans+=cnt_c//4
  print(ans)
# Judge status: Wrong Answer
x = int(input())
p = 100
count = 0
while p<x:
    count = count + 1
    p = p+(p*0.01)

print(count)
# Judge status: Wrong Answer
s = input()
s2 = s.split('dream')
s3 = ''.join(s2).split('erase')
try:
  s3.remove('er')
  s3.remove('r')
except ValueError:
  pass
if s3[0] != '':
  print("NO")
else:
  print("YES")
# Judge status: Accepted
import math
N = int(input())
print(1000*math.ceil(N/1000)-N)
# Judge status: Accepted
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

dp = [10**10] * (H + 1)
dp[H] = 0

for a, b in AB:
    for h in range(H + 1)[:: -1]:
        dp[h] = min(dp[h], dp[min(H, h + a)] + b)

print(dp[0])
# Judge status: Accepted
n=int(input())

print(-1*(-1*n//2))
# Judge status: Wrong Answer
A = list(map(int,input().split()))
A_unique = list(set(A))
A_length = len(A_unique)

if A_length == 2:
    print("YES")

else:
    print("NO")
# Judge status: Accepted
from __future__ import print_function

import sys
input = sys.stdin.readline


def main():
    a, b, c = map(int, input().strip().split())
    for k in range(1, b + 1):
        if (k * a) % b == c:
            print("YES")
            return
    print("NO")
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
A,B = map(int,input().split())

if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")
# Judge status: Accepted
import heapq
n,m=map(int,input().split())
d=[]
for i in range(n):
  a,b=map(int,input().split())
  d.append([a,b])
d=sorted(d, key=lambda student: student[0])
pointer=0
queue=[]
ans=0
for i in range(m+1):
  while pointer<n and d[pointer][0]==i:
    heapq.heappush(queue,-d[pointer][1])
    pointer+=1
    if pointer>=n:
      break
  if queue:
    ans+=heapq.heappop(queue)
print(-ans)
# Judge status: Wrong Answer
n = int(input())
a = {}
for _ in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1
m = int(input())
for _ in range(m):
    s = input()
    if s in a:
        a[s] -= 1
    else:
        a[s] = -1

ans = 0
for i in a:
    if a[i] > 0:
        ans += a[i]
print(ans)
# Judge status: Accepted
x=input()
if x[2]==x[3] and x[4]==x[5]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n,m=[int(x) for x in input().rstrip().split()]
ll=[]
rl=[]
for i in range(m):
  l,r=[int(x) for x in input().rstrip().split()]
  ll.append(l)
  rl.append(r)

ans=0
if min(rl)-max(ll)<0:
  print(0)
else:
  print(min(rl)-max(ll)+1)
# Judge status: Wrong Answer
n = input().split()
N = int(n[0])
K = int(n[1])
a = input().split()
sum = 0
max = 0
for j in range(0, N):
    sum += int(a[j])
    if j > K - 1:
      sum -= int(a[j - K])
      if max < sum:
        max = sum
e = (max + K) / 2 if (max + K) % 2 == 0 else str(int((max + K - 1) / 2)) + '.5'
print (e)
# Judge status: Wrong Answer
def p_b():
    n = int(input())
    t, a = map(int, input().split())
    *H, = map(int, input().split())
    ans = 10**9
    idx = -1
    for i, h in enumerate(H):
        if ans > abs(a - (t - h * 0.006)):
            ans = abs(t - h * 0.006)
            idx = i + 1
    print(idx)
    
p_b()
# Judge status: Accepted
N = int(input())
n = 0
a = n ** 2 + n - 2 * N
# 上から抑える
while a < 0:
    n += 1
    a = n ** 2 + n - 2 * N

score = 0
ans = []
for i in reversed(range(1, n + 1)):
    if score + i <= N:
        score += i
        ans.append(i)
    if score == N:
        break

for i in ans:
    print(i)
# Judge status: Accepted
a, b = map(int, input().split())
x = (a+b)/2
# print(x)
m, n = divmod(x,1)
# print("{},{}".format(m,n))
if n>0:
    ans = m+1
else:
    ans = m
print(int(ans))
# Judge status: Wrong Answer
N=int(input())
a=[int(s) for s in input().split(" ")]

List=[]
last_index=0
for number in range(1,N+1):
    for index in range(last_index,N):
        if number==a[index]:
            List.append(number)
            last_index=index
            break
                
print(-1 if List[0]!=1 else N-len(List))
# Judge status: Wrong Answer
H1,M1,H2,M2,K=map(int,input().split())
if H2-H1<0:
    print(0)
else:
    if M2-M1<0:
        print(0)
    else:
        if M2>=M1:
            print(((H2-H1)*60+(M2-M1))-K)
        else:
            print(((H2-H1-1)*60+(M1-M2))-K)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))
from fractions import gcd
def Lcm(x):
  L = 1
  for a in x:
    a=a//2
    L = (a // gcd(a, L))*L
  return L
X=Lcm(A)
fg = 0
for i in A:
  if (X//(i//2))%2==0:
    fg=1
    break
if fg==1:
  print(0)
else:
  print(((M//X)+1)//2)
# Judge status: Wrong Answer
n = int(input())
maxx1 =maxx2 =0
minn1 = minn2 =  2000000001
for i in range(n):
    x,y = map(int,input().split())
    minn1 = min(minn1,x+y)
    maxx1 = max(maxx1,x+y)
    minn2 = min(minn2,abs(x-y))
    maxx2 = max(maxx2,abs(x-y))
print(max(maxx1-minn1,maxx2+minn2))
# Judge status: Wrong Answer
N = int(input())
table = [[int(i) for i in input().split()] for N in range(N)]

a = -1
b = 10**9 * 2 + 1
c = -1
d = 10**9 * 2 + 1
for i in range(N):
    p = table[i][0]
    q = table[i][1]
    if a < p+q:
        a = p+q
    if b > p+q:
        b = p+q
    if c < p-q:
        c = p-q
    if d > p-q:
        d = p-q

print(max(a-b,c-d))
# Judge status: Accepted
n=int(input())
a=[]
b=[]
d=0
for i in range(n):
  c=int(input())
  d+=c
  if c%10==0:
    a.append(c)
  else:
    b.append(c)
b.sort()
if d%10==0 and b:
  print(d-b[0])
elif d%10==0:
  print(0)
else:
  print(d)
# Judge status: Accepted
A,B,C,X,Y = map(int,input().split())
sumAB = A+B
if sumAB >= 2*C:
    minXY = min(X,Y)
    ans = min(X,Y)*2*C
    X -= minXY
    Y -= minXY
    if X != 0:
        ans += X*min(A,2*C)
    elif Y !=0:
        ans += Y*min(B,2*C)
    print(ans)

else:
    print(A*X+Y*B)
# Judge status: Wrong Answer
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
if L[0] > (sum(L)-L[0]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = [0]
a += list(map(int, input().split()))

b = [0]*(n+1)

for i in range(n,0,-1):
    sum = 0
    for j in range(2*i, n+1, i):
        sum ^= b[j]
    b[i] = sum^a[i]
    
ans = []
for i in range(1,n+1):
    if b[i]: ans.append(i)

print(len(ans))
print(*ans)
# Judge status: Wrong Answer
import itertools

N = int(input())

permu = [i+1 for i in range(N)]
s = 0
flag = False

P = tuple([int(i) for i in input().split(" ")])
Q = tuple([int(i) for i in input().split(" ")])

# print(P)
for i, value in enumerate(itertools.permutations(permu)):
    
    if P == Q:
        break

    if value == P or value == Q:
        # print(i)
        if flag:
            s -= i
        else:
            s += i
            flag = True
# Judge status: Accepted
S = int(input())
v = 10**9
b2 = (S+v-1)//v
b1 = v*b2-S
print(v, 1, 0, 0, b1, b2)
# Judge status: Accepted
import sys

n = int(input())

if n == 1:
    print(0)
    sys.exit()

count = 0
i = 2

while True:
    if i * i > n:
        break

    e = 0
    while n % i == 0:
        n = n // i
        e += 1
    curr = 1
    while e >= curr:
        e -= curr
        curr += 1
        count += 1
    i += 1

if n > 1:
    print(count + 1)
else:
    print(count)
# Judge status: Wrong Answer
a, b, k = map(int, input().split())

ans = []

for i in [t for t in range(a, b)][:k]:
    ans.append(i)

for i in [t for t in range(b, a, -1)][:k]:
    ans.append(i)

ans = list(set(ans))
ans.sort()
for o in ans:
    print(o)
# Judge status: Accepted
a,b = map(int,input().split())
fl = 0
for i in range(10000):
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i)
        fl = 1
        break
if fl ==0:
    print(-1)
# Judge status: Accepted
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a=nl()
k=ni()

for i in range(k):
  a = sorted(a)[::-1]
  a[0]*=2

print(sum(a))
# Judge status: Accepted
a,b,c,x,y=map(int,input().split())
if a>=2*c and b>=2*c:
    print(max(x,y)*2*c)
elif a<2*c and b>=2*c:
    print(y*2*c + max(0,x-y)*a)
elif a>=2*c and b<2*c:
    print(x*2*c + max(0,y-x)*b)
elif a+b>2*c:
    if x>y:
        print(y*2*c+(x-y)*a)
    else:
        print(x*2*c+(y-x)*b)
else:
    print(a*x+b*y)
# Judge status: Accepted
N = input()
A = int(N[0])*111
print((int(N[0])+1)*111 if int(N) > A else A)
# Judge status: Wrong Answer
x=int(input())
c=100
year=0
while (x+1!=c):
  year+=1
  c+=1
print(year)
# Judge status: Wrong Answer
N = int(input())
print(N*800-15//N*200)
# Judge status: Accepted
N,H=map(int,input().split())
B=[]
A=0
for _ in range(N):
    a,b=map(int,input().split())
    A=max(A,a)
    B.append(b)
B.sort(reverse=True)
ans=(H-1)//A+1
for i in range(N):
    H-=B[i]
    if H<=0:
        ans=min(ans,i+1)
        break
    ans=min(ans,(H-1)//A+1+i+1)
print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
x = list(map(int, input().split()))

if x[0] >= 0:
    print(x[k - 1])
    exit()
elif x[n - 1] < 0:
    print(x[n - k])
    exit()
else:
    for i in range(n):
        if x[i] >= 0:
            ori = i
            break

f_inf = float("inf")
res = f_inf
for i in range(max(ori - k, 0), min(ori + k, n) - k + 1):
    time = abs(x[i]) + abs(x[i + k - 1] - x[i])
    res = min(res, time)

print(res)
# Judge status: Wrong Answer
N=int(input())
d=[int(s) for s in input().split(" ")]

d.sort()

if (N//2)%2==0:
    print(0)
else:
    K=d[(N//2)]-d[(N//2)-1]
    if d[N//2]!=d[(N//2)-2] and K==0:
        K=1
    elif d[N//2]==d[(N//2)-2]:
        K=0
    print(K)
# Judge status: Wrong Answer
l=list(input())
if l[0]==l[1] and l[2]==l[3]:
  print("Yes")
elif l[0]==l[2] and l[1]==l[3]:
  print("Yes")
elif l[0]==l[3] and l[1]==l[2]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
x,y = map(int,input().split())

ans = 0
while x < y:
    x *= 2
    ans += 1

if x == y:
    ans += 1

print(ans)
# Judge status: Wrong Answer
S = list(map(int,input()))
for i in range(len(S)):
  if S[i] != 1:
    print(S[i])
    break
# Judge status: Wrong Answer
x,y=map(int,input().split())
z=y/x
cnt=0
while z>=1:
  cnt+=1
  z/=2
print(cnt)
# Judge status: Accepted
from math import ceil
N, H = map(int, input().split())
B = []
a = 0
for i in range(N):
  aa, b = map(int, input().split())
  if a < aa:
    a = aa
  B.append(b)
B.sort(reverse=True)

res = 0
for b in B:
  if a < b:
    H -= b
  else:
    break
  res += 1
  if H <= 0:
    break

if H <= 0:
  print(res)
else:
  print(res+ceil(H/a))
# Judge status: Accepted
a, b, c = sorted(map(int,input().split()))
print(c*10+b+a)
# Judge status: Wrong Answer
K = "keyence"
S = input()

for i in range(len(K) + 1):
    l, r = K[:i], K[i:]
    if l in S and r in S:
        print("YES")
        break
else:
    print("NO")
# Judge status: Accepted
x, y = input("").split(" ")
a = int(x)
b = int(y)
result = 0
if a >= 13:
  result = b
elif a >= 6 and a <= 12:
  result = b//2
else:
  result = 0
print(result)
# Judge status: Accepted
#B - Guidebook AC(ヒント)
N = int(input())
S = []
P = []
for _ in range(N):
    s,p = input().split()
    S.append(s)
    P.append(int(p)*(-1))#負の値にして降順にソートできるようにする

book = list(zip(S,P))
book_sort = sorted(book)
ans = [book.index(i)+1 for i in book_sort]
for j in ans:
    print(j)
# Judge status: Wrong Answer
from collections import Counter

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

ans = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    v = a[b]
    a[c] += v
    a[b] = 0
    ans += (c - b) * v
    print(ans)
# Judge status: Wrong Answer
a, b, c = map(lambda x: int(x), input().split())
if a * c <= b:
  print(a * c)
else:
  print(int(b/a))
# Judge status: Accepted
S = input()

def it(s):
    c = 0
    for v in s:
        if v == 'R':
            c += 1
        else:
            c = 0
        yield c

print(max(it(S)))
# Judge status: Wrong Answer
l = list(map(int,input().split()))
ans = 0
if l[0] == l[1] == l[2]:
  print(-1)
  exit()
while all(i % 2 == 0 for i in l):
  a = l[0]//2; b = l[1]//2; c = l[2]//2;
  l[0] = b + c
  l[1] = a + c
  l[2] = a + b
  ans += 1
print(ans)
# Judge status: Accepted
t = input()
print(t.replace('?', 'D'))
# Judge status: Accepted
n, k = list(map(int, input().split(' ')))
p = list(map(int, input().split(' ')))
p = sorted(p)

print(sum(p[0:k]))
# Judge status: Accepted
a, b = map(int, input().split())
print('safe' if a > b else 'unsafe')
# Judge status: Accepted
import sys
def minimumchar(s1,s2):
	n,m=len(s1),len(s2)
	ans=sys.maxsize
	for i in range(m-n+1):
		minRemovedChar=0
		for j in range(n):
			if (s1[j]!=s2[i+j]):
				minRemovedChar+=1
		ans=min(minRemovedChar,ans)
	return ans
	
s2=input()
s1=input()

print(minimumchar(s1,s2))
# Judge status: Wrong Answer
n = int(input())
mod = 10**9+7
print(pow(10, n, mod) - (pow(9, n, mod) + pow(9, n, mod)) + pow(8, n, mod))
# Judge status: Accepted
a,b = map(int, input().split())
if a < b:
  print(str(a) * b)
else:
  print(str(b) * a)
# Judge status: Accepted
S = input()

l = len(S)
pre = ''
flag = 0
count = 0

for i in range(l):
    if flag == 1:
        flag = 0
        continue

    try:
        tmp = S[i]
        if tmp == pre:
            flag = 1
            pre = tmp + S[i+1]
            count += 1
        else:
            pre = tmp
            count += 1
    except IndexError:
        pass

print(count)
# Judge status: Accepted
a, b = map(int, input().split())
if (a * b) & 1:
    print('Odd')
else:
    print('Even')
# Judge status: Accepted
import math
n = int(input())
l = 0

x_list = []
y_list = []

for i in range(n):
    x, y = map(int, input().split())
    x_list.append(x)
    y_list.append(y)

for j in range(n):
    for k in range(n):
        if j >= k:
            continue
        l += math.sqrt((x_list[j] - x_list[k]) ** 2 + (y_list[j] - y_list[k]) ** 2)

print(l * 2/n)
# Judge status: Accepted
n = int(input())
shiritori = []
for _ in range(n):
    shiritori.append(input())

if len(set(shiritori)) != n:
    print ("No")
    exit ()

for i in range(n-1):
    if shiritori[i][-1] != shiritori[i+1][0]:
        print ("No")
        exit ()
else:
    print ("Yes")
# Judge status: Accepted
s = input()
if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
V = [0]*(N+1)
flug = 0
Lsum= sum(A)

V[0] = 1
for i in range(1,N):
    V[i] = (V[i-1]*2 - A[i])
    if V[i] <= 0:
        flug = 1
    Lsum = Lsum - A[i]
    if V[i] > Lsum :
        V[i] = Lsum
V[N]=0
#print(V)
 
ans = sum(V)+sum(A)
if A[0] != 0:
    ans = -1
if flug ==1:
   ans = -1
if N == 0:
    ans = -1

print(ans)
# Judge status: Accepted
c = [[int(i) for i in input().split()] for _ in range(3)]
print('Yes') if c[0][0]+c[1][1]+c[2][2] == c[0][1]+c[1][2]+c[2][0] == c[0][2]+c[1][0]+c[2][1] else print('No')
# Judge status: Accepted
import math
X=int(input())

def check_p(X,b):
	p = 0
	while b**(p+1) <= X:
		p+=1
	return b**p

ans=1
for b in range(2,int(math.sqrt(X))+1):
	ans = max(ans,check_p(X,b))

print(ans)
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=float(b)

print(int(a*b+0.0001))
# Judge status: Accepted
k=int(input())
s=input()

if len(s)<=k:
    print(s)
else:
    print(s[:k]+"...")
# Judge status: Accepted
#!/usr/bin/env python3

n = int(input())

list_ = [0]*(10**4)
for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= 10**4:
                list_[a-1] += 1

for i in range(n):
    print(list_[i])
# Judge status: Accepted

c = input()
if c in "aiueo" :
    print("vowel")
else :
    print("consonant")
# Judge status: Accepted
n = int(input())
ans = 114514
for i in range(1, n):
    a = list(map(int, list(str(i))))
    b = list(map(int, list(str(n - i))))
    c = sum(a) + sum(b)
    ans = min(ans, c)
print(ans)
# Judge status: Wrong Answer
N = int(input())
a, w, t, r = 0, 0, 0, 0
for i in range(N):
    S = input()
    if S == 'AC':
        a += 1
    elif S == 'WA':
        w += 1
    elif S == 'TLE':
        t += 1
    else:
        r += 1
print('AC × ' + str(a))
print('WA × ' + str(w))
print('SLE × ' + str(t))
print('RE × ' + str(r))