Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
print("Yes" if t[:len(s)]==s and len(s)+1==len(t) else "No")

Buggy submission (verdict: Runtime Error):
import sys
a,b,c,k=map(int,input().split())
ans=0
if a<=k:
    ans=a
    k=k-a
else:
    print(k)
    sys.exit()
if k!=0:
    k=k-b
else:
    print(a)
    sys.exit()
if k>0:
    ans=ans-k
    print(ans)
else:
    print(a)
Problem p03000 (python)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
i=z=0
while z<=x and i<n:
    z+=l[i]
    i+=1
if z<=x:
    i+=1
print(i)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
i=z=0
while z<=x:
    z+=l[i]
    i+=1
print(i)
Problem p03338 (python)

Fixed submission:
n=int(input())
s=input()
ans=[]
for i in range(n):
    ans.append(len(set((s[:i]))&(set(s[i:]))))
print(max(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=[]
for i in range(1,n-1):
    ans.append(len(set((s[:i]))&(set(s[i:]))))
print(max(ans))
Problem p03644 (python)

Fixed submission:
s=int(input())
two=[]
for i in range(8):
    two.append(2**i)
ans=0
if s in two:
    print(s)
else:
    while s>two[ans]:
        ans+=1
    print(2**(ans-1))

Buggy submission (verdict: Runtime Error):
s=int(input())
two=[]
for i in range(7):
    two.append(2**i)
ans=0
if s in two:
    print(s)
else:
    while s>two[ans]:
        ans+=1
    print(2**(ans-1))
Problem p04011 (python)

Fixed submission:
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n > k:
    print(k*x + (n-k)*y)
else:
    print(n*x)

Buggy submission (verdict: Runtime Error):
def takahashi(n, k, x, y):
    if n > k:
        return (n-k+1)*x + (k-1)*y
    else:
        return n*x
    


n,k,x,y = list(map(int, input().split()))
takahashi(n,k,x,y)
Problem p02608 (python)

Fixed submission:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    f = [{} for _ in range(N+1)] # [{arg:k}]
    if len(f) > 6:
        f[6] = {(1,1,1):1}
    for i in range(N):
        args = f[i]
        for (x,y,z),k in args.items():
            index = i + 2*x + y + z + 1
            arg = (x+1,y,z)
            if index < N+1:
                f[index][arg] = 1
            index = i + x + 2*y + z + 1
            arg = (x,y+1,z)
            if index < N+1:
                f[index][arg] = 1
            index = i + x + y + 2*z + 1
            arg = (x,y,z+1)
            if index < N+1:
                f[index][arg] = 1

    for i in range(1,N+1):
        print(sum(f[i].values()))


main()

Buggy submission (verdict: Runtime Error):
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    f = [{} for _ in range(N+1)] # [{arg:k}]
    f[6] = {(1,1,1):1}
    for i in range(N):
        args = f[i]
        for (x,y,z),k in args.items():
            index = i + 2*x + y + z + 1
            arg = (x+1,y,z)
            if index < N+1:
                f[index][arg] = 1
            index = i + x + 2*y + z + 1
            arg = (x,y+1,z)
            if index < N+1:
                f[index][arg] = 1
            index = i + x + y + 2*z + 1
            arg = (x,y,z+1)
            if index < N+1:
                f[index][arg] = 1

    for i in range(1,N+1):
        print(sum(f[i].values()))


main()

Buggy submission (verdict: Runtime Error):
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    f = [{} for _ in range(N+1)] # [{arg:k}]
    f[6] = {(1,1,1):1}
    for i in range(N):
        args = f[i]
        for (x,y,z),k in args.items():
            index = i + 2*x + y + z + 1
            arg = (x+1,y,z)
            if index < N+1:
                f[index].update({arg: f[index].get(arg,0)+k})
            index = i + x + 2*y + z + 1
            arg = (x,y+1,z)
            if index < N+1:
                f[index].update({arg: f[index].get(arg,0)+k})
            index = i + x + y + 2*z + 1
            arg = (x,y,z+1)
            if index < N+1:
                f[index].update({arg: f[index].get(arg,0)+k})

    #print(f)
    for i in range(1,N+1):
        print(sum(f[i].values()))


main()
Problem p02646 (python)

Fixed submission:
(A, V) = map(lambda a: float(a), input().split())
(B, W) = map(lambda a: float(a), input().split())
T = float(input())

D = abs(A - B)
X = V - W

if (X*T >= D):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
(A, V) = map(lambda a: double(a), input().split())
(B, W) = map(lambda a: double(a), input().split())
T = double(input())

D = abs(A - B)
X = abs(V - W)

if (X*T >= D):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
(A, V) = input().split()
(B, W) = input().split()
T = input()

D = abs(A - B)
X = abs(x - Y)

if (X*T >= D):
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
(A, V) = input().split()
(B, W) = input().split()
T = input()

D = abs(A - B)
X = abs(x - Y)

if X*T >= D:
  print("OK")
else:
  print("NG")
Problem p02647 (python)

Fixed submission:
import numpy as np
from numba import njit

(N, K) = map(int, input().split())
A = np.array(list(map(int, input().split())))

@njit
def solve(N,K,A):
    for j in range(0, K):
        B = np.zeros(N, dtype=np.int64)

        for i in range(0,N):
            f = max(0, i - A[i])
            t = min(N-1, i + A[i])
            #for j in range(max(0, f), min(N, t)+1):
            #    B[j] += 1
            B[f] += 1
            if t+1 < N:
                B[t+1] -= 1
        A = np.cumsum(B)
        if np.all(A == N):
            return A
        i += 1
    return A
    

print(" ".join(map(str, solve(N,K,A))))

Buggy submission (verdict: Runtime Error):
(N, K) = map(lambda a: int(a), input().split())
A = map(lambda a: int(a), input().split())


def proc():
    global A
    B = [0 for _ in range(N)]

    for i in range(1,N):
        f = i - A[i]
        t = i + A[i]
        for j in range(max(1, f), min(N, t)):
            B[j] += 1
    
    A = B

for _ in range(1, K):
    proc()

print(" ".join(A))

Buggy submission (verdict: Runtime Error):
(N, K) = map(lambda a: int(a), input().split())
A = map(lambda a: int(a), input().split())


def proc():
    B = [0 for _ in range(N)]

    for i in 1 to N:
        f = i - A[i]
        t = i + A[i]
        for j in max(1, f) to min(N, t):
            B[j] += 1
    
    A = B

for _ in 1 to K:
    proc()

print(" ".join(A))
Problem p02660 (python)

Fixed submission:
import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d.update({i: cnt})

    if temp!=1:
        d.update({temp: 1})

    if d==[]:
        d.update({n:1})

    return d

def main():
    N = int(input())
    d = factorization(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d.append({i, cnt})

    if temp!=1:
        d.append({temp, 1})

    if d==[]:
        d.append({n, 1})

    return d

def main():
    N = int(input())
    d = factorization(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
from decimal import *
import sympy
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def main():
    N = int(input())
    d = sympy.factorint(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()
Problem p02678 (python)

Fixed submission:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    (N, M) = map(int, input().split())
    neighbor = [[] for _ in range(N+1)]
    for _ in range(M):
        (A,B) = map(int, input().split())
        neighbor[A] += B,
        neighbor[B] += A,

    guide = [0 for _ in range(N+1)]

    # 1の部屋から幅優先で道しるべを置く
    
    # 探索候補
    target = [1]
    checked = [1]
    while len(target) > 0:
        # 候補の先頭から取る
        n = target.pop(0)
        # nから伸びる行き先
        dests = neighbor[n]
        # すでに道しるべがあるものは除く
        dests = filter(lambda d: guide[d] == 0, dests)
        # 道しるべを置く
        for d in dests:
            guide[d] = n
            checked += d,
            # 探索候補の末尾に追加
            target += d,

    print('Yes')
    for i in range(2,N+1):
        print(guide[i])

main()

Buggy submission (verdict: Runtime Error):
import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    (N, M) = map(int, input().split())
    neighbor = {}
    for _ in range(M):
        (A,B) = map(int, input().split())
        na = neighbor.get(A, [])
        nb = neighbor.get(B, [])
        neighbor.update({A:na+B})
        neighbor.update({B:nb+A})

    guide = {1:1}

    # 1の部屋から幅優先で道しるべを置く
    
    # 探索候補
    target = [1]
    while len(target) > 0:
        # 候補の先頭から取る
        n = target.pop(0)
        # nから伸びる行き先
        dests = neighbor.get(n, [])
        # すでに道しるべがあるものは除く
        dests = list(filter(lambda d: not d in guide.keys(), dests))
        # 道しるべを置く
        for d in dests:
            guide.update({d:n})
            # 探索候補の末尾に追加
            target += d,

    if set(range(1,N+1)) <= set(guide.keys()):
        print('Yes')
        for i in range(2,N+1):
            print(guide[i])
    else:
        print('No')

main()
Problem p02698 (python)

Fixed submission:
#import numpy as np
#import math
#from decimal import *
#from numba import njit
from bisect import bisect_left

#@njit
def main():
    N = int(input())
    a = list(map(int, input().split()))
    edges = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u,v = map(int, input().split())
        edges[u] += v,
        edges[v] += u,

    ans = [0]*(N+1)
    lastLis = []
    visited = [False]*(N+1)
    parent = {}
    n = 1
    stack = []
    while True:
        #print(n, lastLis, stack)
        if not visited[n]:
            if len(lastLis) == 0 or a[n-1] > lastLis[-1]:
                lastLis.append(a[n-1])
                stack += (len(lastLis)-1, -1),
            else:
                index = bisect_left(lastLis, a[n-1])
                stack += (index, lastLis[index]),
                lastLis[index] = a[n-1]
            ans[n] = len(lastLis)
            visited[n] = True
        hasNext = False
        for d in edges[n]:
            if not visited[d]:
                parent[d] = n
                n = d
                hasNext = True
        if not hasNext:
            if n == 1:
                n = 0
                break
            n = parent[n]
            # 巻き戻し
            index, value = stack.pop(len(stack)-1)
            if value < 0:
                lastLis.pop(index)
            else:
                lastLis[index] = value

    for i in range(1, len(ans)):
        print(ans[i])




main()

Buggy submission (verdict: Runtime Error):
#import numpy as np
#import math
#from decimal import *
#from numba import njit
from bisect import bisect_left

#@njit
def main():
    N = int(input())
    a = list(map(int, input().split()))
    edges = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u,v = map(int, input().split())
        edges[u] += v,
        edges[v] += u,

    ans = [0]*(N+1)
    lastLis = []
    visited = [False]*(N+1)
    parent = {}
    n = 1
    stack = []

    def rec(n):
        nonlocal lastLis,stack
        #print(n, lastLis, stack)
        if not visited[n]:
            if len(lastLis) == 0 or a[n-1] > lastLis[-1]:
                lastLis.append(a[n-1])
                stack += (len(lastLis)-1, -1),
            else:
                index = bisect_left(lastLis, a[n-1])
                stack += (index, lastLis[index]),
                lastLis[index] = a[n-1]
            ans[n] = len(lastLis)
            visited[n] = True
        else:
            pass
        hasNext = False
        for d in edges[n]:
            if not visited[d]:
                parent[d] = n
                rec(d)
                hasNext = True
        # 巻き戻し
        index, value = stack.pop(len(stack)-1)
        if value < 0:
            lastLis.pop(index)
        else:
            lastLis[index] = value

    rec(1)
    for i in range(1, len(ans)):
        print(ans[i])




main()
Problem p02755 (python)

Fixed submission:
import math
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

a1 = math.ceil(a / 0.08)
a2 = math.ceil((a+1) / 0.08)
b1 = math.ceil(b / 0.1)
b2 = math.ceil((b+1) / 0.1)
# alist = list(range(a1, a2))
# blist = list(range(b1, b2))

# print(alist)
# print(blist)
for i in range(a1, a2):
    for j in range(b1, b2):
        if i == j:
            print(i)
            # print(i * 0.08)
            # print(i * 0.1)
            exit(0)
print(-1)

Buggy submission (verdict: Runtime Error):
import math
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

a1 = math.ceil(a / 0.08)
a2 = math.ceil((a+1) / 0.08)
b1 = math.ceil(b / 0.1)
b2 = math.ceil((b+1) / 0.1)
# alist = list(range(a1, a2))
# blist = list(range(b1, b2))

# print(alist)
# print(blist)
for i in range(a1, a2):
    for j in range(b1, b2):
        if i == j:
            print(i)
            # print(i * 0.08)
            # print(i * 0.1)
            exit(1)
print("-1")

Buggy submission (verdict: Runtime Error):
import math
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

a1 = math.ceil(a / 0.08)
a2 = math.ceil((a+1) / 0.08)
b1 = math.ceil(b / 0.1)
b2 = math.ceil((b+1) / 0.1)
# alist = list(range(a1, a2))
# blist = list(range(b1, b2))

# print(alist)
# print(blist)
for i in range(a1, a2):
    for j in range(b1, b2):
        if i == j:
            print(i)
            # print(i * 0.08)
            # print(i * 0.1)
            exit(1)
print(-1)

Buggy submission (verdict: Runtime Error):
import math
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

a1 = math.ceil(a / 0.08)
a2 = math.ceil((a+1) / 0.08)
b1 = math.ceil(b / 0.1)
b2 = math.ceil((b+1) / 0.1)
alist = list(range(a1, a2))
blist = list(range(b1, b2))

# print(alist)
# print(blist)
for i in alist:
    for j in blist:
        if i == j:
            print(i)
            # print(i * 0.08)
            # print(i * 0.1)
            exit(1)
print(-1)

Buggy submission (verdict: Runtime Error):
import math
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

a1 = math.ceil(a / 0.08)
a2 = math.ceil((a+1) / 0.08)
b1 = math.ceil(b / 0.1)
b2 = math.ceil((b+1) / 0.1)
alist = list(range(a1, a2))
blist = list(range(b1, b2))

# print(alist)
# print(blist)
for i in alist:
    for j in blist:
        if i == j:
            print(i)
            exit(1)
print(-1)

Buggy submission (verdict: Runtime Error):
import math
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

a1 = math.ceil(a / 0.08)
a2 = math.ceil((a+1) / 0.08)
b1 = math.ceil(b / 0.1)
b2 = math.ceil((b+1) / 0.1)
alist = range(a1, a2)
blist = range(b1, b2)

for i in alist:
    for j in blist:
        if i == j:
            print(i)
            exit(1)
print(-1)

Buggy submission (verdict: Runtime Error):
input1 = list(map(int, (input().split())))

a = input1[0]
b = input1[1]

for i in range(1, 101):
    c = int(i * 0.08)
    d = int(i * 0.10)
    if a == c and b == d:
        print(i)
        exit(1)
print(-1)
Problem p02612 (python)

Fixed submission:
N = int(input())
if (N%1000==0):
  print(0)
else:
  print(1000 - (N%1000))

Buggy submission (verdict: Runtime Error):
N = int(input)
if (N%1000==0):
  print(0)
else:
  print(1000 - (N%1000))

Buggy submission (verdict: Runtime Error):
N = int(input)
print(1000 - (N%1000))
Problem p02640 (python)

Fixed submission:
X, Y = map(int, input().split())

if (Y%2 == 1):
  print("No")
elif (Y > (X*4)):
  print("No")
else:
  yes = False
  for i in range(0,X+1):
    fNum = i
    tNum = X-i
    if ((fNum*4)+(tNum*2)==Y):
      print("Yes")
      yes = True
  if not (yes):
    print("No")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

if (Y%2 == 1):
  print("No")
elif (Y > (X*4)):
  print("No")
else:
  yes = False
  for i in range(1,X+1):
    fNum = i
    tNum = X-i
    if ((fNum*4)+(tNum*2)==Y):
      print("Yes")
      yes = True
  if not (false):
    print("No")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

if (Y%2 == 1):
  print("No")
elif (Y > (X*4)):
  print("No")
else:
  yes = false
  for i in range(1,X+1):
    fNum = i
    tNum = X-i
    if ((fNum*4)+(tNum*2)==Y):
      print("Yes")
      yes = True
  if not (false):
    print("No")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().s .- 0   			111						/plit())

if (Y%2 == 1):
  print("No")
elif (Y > (X*4)):
  print("No")
else:
  print("Yes")
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
if (N == 0):
  print(X)
else:
  nums = list(map(int, input().split()))
    
  nums.sort()
  low = nums[0]
  high = nums[-1]
  minDiff = 100000000
  minNum = -1
  for i in range(-10, 110):
    if i in nums:
      continue
    else:
      Dif = abs(X-i)
    if (Dif < minDiff):
      minDiff = Dif
      minNum=i
  print(minNum)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
low = nums[0]
high = nums[-1]
minDiff = 100000000
minNum = -1
for i in range(low+1, high):
  if i in nums:
    continue
  else:
    Dif = abs(X-i)
    if (Dif < minDiff):
      minDiff = Dif
      minNum=i

if (minNum == -1):
  print(X)
else:
  print(minNum)
Problem p02642 (python)

Fixed submission:
N = int(input())
nums = list(map(int, input().split()))
nums.sort()
div_length = max(nums)+1
divisible_list = {}
#initialize
for i in range(0, div_length):
  divisible_list[i] = 0

#count divisible numbers
for fNum in nums:
  for j in range(fNum, div_length, fNum):
   	divisible_list[j] += 1

#check for numbers
answer = 0
for num in nums:
  if (divisible_list[num] == 1):
    answer += 1
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
nums = list(map(int, input().split()))
count = [0]*N
nums.sort()
answer = N
for i in range(N):
  fNum = nums[i]
  for j in range(N):
    sNum = nums[j]
    if (sNum > fNum):
      break
    elif (i == j):
      continue
    else:
      if (fNum%sNum == 0):
      	answer -= 1
        break

print(answer)
Problem p02647 (python)

Fixed submission:
import math
N, K = map(int, input().split())
lightPow = list(map(int, input().split()))

for i in range(K):
  newLightPow = [0]*(N+1)
  #print(lightPow)
  for pos in range(1, N+1):
    low = pos - lightPow[pos-1]
    high = pos + lightPow[pos-1]
    low = min(max(1, low), N)
    high = min(max(1, high), N)
    newLightPow[low-1] += 1
    newLightPow[high] -= 1
    #print("pos:"+str(pos))
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
    
  check = True
  for i in range(0, N):
    if (i > 0):
      newLightPow[i] += newLightPow[i-1]
    if (newLightPow[i] < N):
      check = False
  lightPow = newLightPow
  if (check):
    break

print(*lightPow[:-1])

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
lightPow = list(map(int, input().split()))

for i in range(K):
  newLightPow = [0]*N
  for pos in range(1, N+1):
    count = 0
    low = max(math.ceil(pos-(lightPow[pos-1]+0.5)), 1)
    high = max(math.floor(pos+(lightPow[pos-1]+0.5)), 1)

    for area in range(low, high+1):
      newLightPow[area-1] += 1
    #print(pos)
    #print("low"+str(low)+" high"+str(high))
    #print(newLightPow)
  lightPow = newLightPow
  
print(*lightPow)
Problem p02663 (python)

Fixed submission:
H1, M1, H2, M2, K = map(int, input().split())

startTime = (H1*60)+M1
endTime = (H2*60)+M2
time = endTime - startTime
posTime = time - K
if (posTime < 0):
  print(0)
else:
  print(posTime)

Buggy submission (verdict: Runtime Error):
H1, M1, H2, M2, K = map(int, input().split())

startTime = (H1*60)+M1
endTime = (H2*60)+M2
time = endTime - startTime
posTime = time - k
if (posTime < 0):
  print(0)
else:
  print(posTime)
Problem p02664 (python)

Fixed submission:
word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif (i == (end-1)):
		word = word.replace('?', "D", 1)   
	elif (word[i-1] == 'P'):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
	else:
		word = word.replace('?', "D", 1)
	start = i + 1
print(word)

Buggy submission (verdict: Runtime Error):
word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif (i == (end-1)):
		word = word.replace('?', "D", 1)   
	elif (word[i-1] == 'P'):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
    else:
      word = word.replace('?', "D", 1)
	start = i + 1
print(word)

Buggy submission (verdict: Runtime Error):
word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif ((i == (end-1)):
		word = word.replace('?', "D", 1)   
    elif (word[i-1] == 'P'):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
	start = i + 1
print(word)

Buggy submission (verdict: Runtime Error):
word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif ((i == (end-1)):
		word = word.replace('?', "D", 1)   
    elif (word[i-1] == 'P')):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
	start = i + 1
print(word)

Buggy submission (verdict: Runtime Error):
word = input()
start = 0
end = len(word)
while(True):
	i = word.find('?', start, end)
	if (i == -1):
		break
	elif ((i == (end-1)):
		word = word.replace('?', "D", 1)   
    elif (word[i-1] == 'P')):
		word = word.replace('?', "D", 1)
	elif ((word[i+1] == "?") or (word[i+1] == "D")):
		word = word.replace('?', "P", 1)
	start = i + 1
print(word)

Buggy submission (verdict: Runtime Error):
word = input()
for (i in range(len(word))):
  if (word[i] == '?'):
    if (word[i-1] == 'P'):
      word[i] = 'D'
    elif(word[i-1] == 'D'):
      word[i] = 'P'
print(word)