Problem:
Score : 200 points

Problem Statement

For a string S consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of S be the total number of occurrences of D and PD in S as contiguous substrings. For example, if S = PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.

We have a string T consisting of P, D, and ?.

Among the strings that can be obtained by replacing each ? in T with P or D, find one with the maximum possible doctoral and postdoctoral quotient.

Constraints

1 \leq |T| \leq 2 \times 10^5

T consists of P, D, and ?.

Input

Input is given from Standard Input in the following format:

T

Output

Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in T with P or D.
If there are multiple such strings, you may print any of them.

Sample Input 1

PD?D??P

Sample Output 1

PDPDPDP

This string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is 6, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in T with P or D.

Sample Input 2

P?P?

Sample Output 2

PDPD

Solution in Python (3.8.2) (judge verdict: Time Limit Exceeded)

import os, sys

# Pの次はDのほうが良いに決まってるので、決め打ち修正
def replaceToD(hoge):
    flg = False
    newStr = ""
    for i in hoge:
        if i == "P":
            flg = True
            newStr += "P"
        if i == "?":
            if flg:
                flg = False
                newStr += "D"
            else:
                newStr += "?"
        if i == "D":
            flg = False
            newStr += "D"

    return newStr

# 入力文字列の博士PDを返す
def calcDoctorPD(hoge):
    leng = len(hoge)

    max=0
    count=0
    flg = False
    for i in hoge:
        if i == "D" :
            count=count+1
            flg = False
        else:
            #Pの場合
            if flg:
                #P連打
                if count > max :
                    max = count
                count=0
                flg = False
            else:
                #初回P
                flg = True
    
    if count > max:
        max = count

    return max


def calcQuestin(hoge):
    return hoge.count("?")
    

str = input()
str = replaceToD(str)
maxstr = str
countQuestion = calcQuestin(str)
loop = 2 ** countQuestion
#print("loop")
#print(loop)
max = calcDoctorPD(str)
now = 0
for num in range(1,loop+1):
    hoge = str
    for num2 in range(1, countQuestion+1):
#        print("Num", num, "num2", num2)
        if num%num2 == 1:
            hoge = hoge.replace("?", "P", 1)
        else:
            hoge = hoge.replace("?", "D", 1)

    now = calcDoctorPD(hoge)
#    print("str", hoge)
#    print("now", now)
    if max < now:
        maxstr = hoge
        max = now





res = max

#print(res)
print(maxstr)

# PD?PD?
# ?2回なのでcountQuestion = 2
# loop = 4
#PP, PD, DP, DD

#a = replaceToD(str)
#print(a)