Buggy python submission (verdict: Runtime Error):
# 初期入力
import sys
input = sys.stdin.readline
T =list(input().strip())
if T[0] =="?":
    if T[1] =="?":
        T[0] ="P"
        T[1] ="D"
    elif T[1] =="D":
        T[0] ="P"
    else:
        T[0] ="D"


for i in range(1,len(T)-1):
    if T[i] =="?":
        if T[i-1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="D":
            T[i] ="P"
        if T[i-1] =="D" and T[i+1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="?":
            T[i] ="P"

if T[-1] =="?":
    T[-1] ="D"

print("".join(T))

Fixed submission:
# 初期入力
import sys
input = sys.stdin.readline
T =list(input().strip())

    
if T[0] =="?":
    if len(T) ==1 :
        T[0] ="D"
    elif T[1] =="?":
        T[0] ="P"
        T[1] ="D"
    elif T[1] =="D":
        T[0] ="P"
    else:
        T[0] ="D"


for i in range(1,len(T)-1):
    if T[i] =="?":
        if T[i-1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="D":
            T[i] ="P"
        if T[i-1] =="D" and T[i+1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="?":
            T[i] ="P"

if T[-1] =="?":
    T[-1] ="D"

print("".join(T))

Buggy python submission (verdict: Runtime Error):
# 初期入力
import sys
input = sys.stdin.readline
T =list(input().strip())
if T[0] =="?":
    if T[1] =="?":
        T[0:2] ="PD"
    elif T[1] =="D":
        T[0] ="P"
    else:
        T[0] ="D"


for i in range(1,len(T)-1):
    if T[i] =="?":
        if T[i-1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="D":
            T[i] ="P"
        if T[i-1] =="D" and T[i+1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="?":
            T[i] ="P"

if T[-1] =="?":
    T[-1] ="D"

print("".join(T))

Fixed submission:
# 初期入力
import sys
input = sys.stdin.readline
T =list(input().strip())

    
if T[0] =="?":
    if len(T) ==1 :
        T[0] ="D"
    elif T[1] =="?":
        T[0] ="P"
        T[1] ="D"
    elif T[1] =="D":
        T[0] ="P"
    else:
        T[0] ="D"


for i in range(1,len(T)-1):
    if T[i] =="?":
        if T[i-1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="D":
            T[i] ="P"
        if T[i-1] =="D" and T[i+1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="?":
            T[i] ="P"

if T[-1] =="?":
    T[-1] ="D"

print("".join(T))

Buggy python submission (verdict: Runtime Error):
# 初期入力
import sys
input = sys.stdin.readline
T =list(input().strip())
if T[0] =="?":
    if T[1] =="?":
        T[0:2] ="PD"
    elif T[1] =="D":
        T[0] ="P"
    else:
        T[0] ="D"


for i in range(1,len(T)-1):
    if T[i] =="?":
        if T[i-1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="D":
            T[i] ="P"
        if T[i-1] =="D" and T[i+1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="?":
            T[i:i+2] ="PD"

if T[-1] =="?":
    T[-1] ="D"

print("".join(T))

Fixed submission:
# 初期入力
import sys
input = sys.stdin.readline
T =list(input().strip())

    
if T[0] =="?":
    if len(T) ==1 :
        T[0] ="D"
    elif T[1] =="?":
        T[0] ="P"
        T[1] ="D"
    elif T[1] =="D":
        T[0] ="P"
    else:
        T[0] ="D"


for i in range(1,len(T)-1):
    if T[i] =="?":
        if T[i-1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="D":
            T[i] ="P"
        if T[i-1] =="D" and T[i+1] =="P":
            T[i] ="D"
        if T[i-1] =="D" and T[i+1] =="?":
            T[i] ="P"

if T[-1] =="?":
    T[-1] ="D"

print("".join(T))