Buggy python submission (verdict: Runtime Error):
t=input()

new=""
for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        if new[-1]=="P":
            new+="D"
        else:
            new+=t[i]

t=new
new=""

for i in reversed(range(len(t))):
    if t[i] != "?":
        new=t[i]+new
    else:
        if new[0]=="D":
            new="P"+new
        else:
            new=t[i]+new

t=new
new=""

for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        new+="D"


print(new)

Fixed submission:
t=input()

new=""
for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        if new=="":
            new+=t[i]
        elif new[-1]=="P":
            new+="D"
        else:
            new+=t[i]

t=new
new=""

for i in reversed(range(len(t))):
    if t[i] != "?":
        new=t[i]+new
    else:
        if new=="":
            new=t[i]+new
        elif new[0]=="D":
            new="P"+new
        else:
            new=t[i]+new

t=new
new=""

for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        new+="D"


print(new)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

t=input()

new=""
ans=-1
ans_new=""
count=0

def func(new,t,i=0):
    global ans,ans_new
    if i==len(t):
        #print(new)
        if ans < new.count("D")+new.count("PD"):
            ans=new.count("D")+new.count("PD")
            ans_new=new
            #print(ans_new)

        return

    if t[i]=="?":
        return func(new+"P",t,i+1) or func(new+"D",t,i+1)
    else:
        return func(new+t[i],t,i+1)

i=0
func(new,t,i)
print(ans_new)


Fixed submission:
t=input()

new=""
for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        if new=="":
            new+=t[i]
        elif new[-1]=="P":
            new+="D"
        else:
            new+=t[i]

t=new
new=""

for i in reversed(range(len(t))):
    if t[i] != "?":
        new=t[i]+new
    else:
        if new=="":
            new=t[i]+new
        elif new[0]=="D":
            new="P"+new
        else:
            new=t[i]+new

t=new
new=""

for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        new+="D"


print(new)

Buggy python submission (verdict: Runtime Error):

t=input()

new=""
ans=0
ans_new=""
count=0

def func(new,t,i=0):
    global ans,ans_new
    if i==len(t):
        #print(new)
        if ans < new.count("D")+new.count("PD"):
            ans=new.count("D")+new.count("PD")
            ans_new=new
            #print(ans_new)

        return

    if t[i]=="?":
        return func(new+"P",t,i+1) or func(new+"D",t,i+1)
    else:
        return func(new+t[i],t,i+1)

i=0
func(new,t,i)
print(ans_new)


Fixed submission:
t=input()

new=""
for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        if new=="":
            new+=t[i]
        elif new[-1]=="P":
            new+="D"
        else:
            new+=t[i]

t=new
new=""

for i in reversed(range(len(t))):
    if t[i] != "?":
        new=t[i]+new
    else:
        if new=="":
            new=t[i]+new
        elif new[0]=="D":
            new="P"+new
        else:
            new=t[i]+new

t=new
new=""

for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        new+="D"


print(new)