Buggy python submission (verdict: Runtime Error):
T=input()
ans=''
i=0
N=len(T)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and i<N-1:
      if ans[-1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='D':
        ans=ans+'P'
      elif ans[-1]=='D' and T[i+1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='?':
        ans=ans+'PD'
        i+=1
    elif i==0:
      if T[i+1]=='D':
        ans=ans+'P'
      elif T[i+1]=='?':
        ans=ans+'PD'
        i+=1
      else:
        ans=ans+'D'
    elif i==N-1:
      ans=ans+'D'

        
  i+=1
print(ans)

Fixed submission:
T=input()
ans=''
i=0
N=len(T)
if N==1 and T=='?':
  print('D')
  exit(0)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and i<N-1:
      if ans[-1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='D':
        ans=ans+'P'
      elif ans[-1]=='D' and T[i+1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='?':
        ans=ans+'PD'
        i+=1
    elif i==0:
      if T[i+1]=='D':
        ans=ans+'P'
      elif T[i+1]=='?':
        ans=ans+'PD'
        i+=1
      else:
        ans=ans+'D'
    elif i==N-1:
      ans=ans+'D'

        
  i+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
T=input()
ans=''
i=0
N=len(T)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and i<N-1:
      if ans[-1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='D':
        ans=ans+'P'
      elif ans[-1]=='D' and T[i+1]=='P':
        ans=ans+'D'
    elif i==0:
      if T[i+1]=='D':
        ans=ans+'P'
      elif T[i+1]=='?':
        ans=ans+'PD'
        i+=1
      else:
        ans=ans+'D'
    elif i==N-1:
      ans=ans+'D'   
  i+=1
print(ans)

Fixed submission:
T=input()
ans=''
i=0
N=len(T)
if N==1 and T=='?':
  print('D')
  exit(0)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and i<N-1:
      if ans[-1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='D':
        ans=ans+'P'
      elif ans[-1]=='D' and T[i+1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='?':
        ans=ans+'PD'
        i+=1
    elif i==0:
      if T[i+1]=='D':
        ans=ans+'P'
      elif T[i+1]=='?':
        ans=ans+'PD'
        i+=1
      else:
        ans=ans+'D'
    elif i==N-1:
      ans=ans+'D'

        
  i+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
T=input()
ans=''
i=0
N=len(T)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and ans[-1]=='P':
      ans=ans+'D'
    elif i==N-1 and ans[-1]=='D':
      ans=ans+'D'
    elif i>0 and i<N-1 and ans[-1]=='D' and T[i+1]=='P':
      ans=ans+'D'
    elif i<N-1 and T[i+1]=='D':
      ans=ans+'P'
    elif i<N-1 and T[i+1]=='?':
      ans=ans+'PD'
      i+=1
  i+=1
print(ans)

Fixed submission:
T=input()
ans=''
i=0
N=len(T)
if N==1 and T=='?':
  print('D')
  exit(0)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and i<N-1:
      if ans[-1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='D':
        ans=ans+'P'
      elif ans[-1]=='D' and T[i+1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='?':
        ans=ans+'PD'
        i+=1
    elif i==0:
      if T[i+1]=='D':
        ans=ans+'P'
      elif T[i+1]=='?':
        ans=ans+'PD'
        i+=1
      else:
        ans=ans+'D'
    elif i==N-1:
      ans=ans+'D'

        
  i+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
T=input()
ans=''
i=0
N=len(T)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:    
    if ans[-1]=='P':
      ans=ans+'D'
    if i<N-1 and T[i+1]=='D':
      ans=ans+'P'
    if i<N-1 and T[i+1]=='?':
      ans=ans+'PD'
      i+=1
  i+=1
print(ans)

Fixed submission:
T=input()
ans=''
i=0
N=len(T)
if N==1 and T=='?':
  print('D')
  exit(0)
while i<N:
  if T[i]!='?':
    ans=ans+T[i]
  else:
    if i>0 and i<N-1:
      if ans[-1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='D':
        ans=ans+'P'
      elif ans[-1]=='D' and T[i+1]=='P':
        ans=ans+'D'
      elif ans[-1]=='D' and T[i+1]=='?':
        ans=ans+'PD'
        i+=1
    elif i==0:
      if T[i+1]=='D':
        ans=ans+'P'
      elif T[i+1]=='?':
        ans=ans+'PD'
        i+=1
      else:
        ans=ans+'D'
    elif i==N-1:
      ans=ans+'D'

        
  i+=1
print(ans)