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

Fixed submission:
import numpy as np
import math
import sys
import bisect
sys.setrecursionlimit(10000000)

def main():
    s = input()
    t = input()
    alphabets = dict.fromkeys(list("abcdefghijklmnopqrstuvwxyz"), None)
    # alphabets = alphabet.copy()
    for key_ in alphabets:
        lists = []
        for i in range(len(s)):
            if key_ == s[i]:
                lists.append(i)
        alphabets[key_] = lists
    now = -1
    count = 0
    for alpha in t:
        if len(alphabets[alpha]) == 0:
            print(-1)
            sys.exit()
        else:
            lists = alphabets[alpha]
            index = bisect.bisect_right(lists, now)
            if index >= len(lists):
                now = -1
                count += len(s)
                now = lists[0]
            else:
                now = lists[index]
            # print(now, count)
    print(count + now + 1)
            







if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
import sys
import bisect
sys.setrecursionlimit(10000000)

def main():
    s = input()
    t = input()
    alphabets = dict.fromkeys(list("abcdefghijklmnopqrstuvwxyz"), None)
    # alphabets = alphabet.copy()
    for key_ in alphabets:
        lists = []
        for i in range(len(s)):
            if key_ == s[i]:
                lists.append(i)
        alphabets[key_] = lists
    # print(alphabets)
    now = -1
    count = 0
    for alpha in t:
        if alphabets[alpha] is None:
            print(-1)
            sys.exit()
        else:
            lists = alphabets[alpha]
            index = bisect.bisect_left(lists, now)
            if index >= len(lists):
                now = -1
                count += len(s)
                index = bisect.bisect_left(lists, now)
                now = lists[index]
            else:
                now = lists[index]
            # print(now, count)
    print(count + now + 1)
            







if __name__ == '__main__':
    main()
Problem p02995 (python)

Fixed submission:
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
    return int(a * b / gcd(a, b))

def main():
    A, B, C, D = [int(c) for c in input().split()]
    N_U = (B) - (A - 1)
    N_C = B // C - (A - 1) // C
    N_D = B // D - (A - 1) // D
    N_C_D = int(B // lcm(C, D) - (A - 1) // lcm(C, D))
    excluded_N_C_D = N_C + N_D - N_C_D
    print(int(N_U - excluded_N_C_D))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)
from math import gcd

def lcm(a, b):
    return int(a * b / gcd(a, b))

def main():
    A, B, C, D = [int(c) for c in input().split()]
    N_U = (B) - (A - 1)
    N_C = B // C - (A - 1) // C
    N_D = B // D - (A - 1) // D
    N_C_D = int(B // lcm(C, D) - (A - 1) // lcm(C, D))
    excluded_N_C_D = N_C + N_D - N_C_D
    print(int(N_U - excluded_N_C_D))


if __name__ == '__main__':
    main()
Problem p03044 (python)

Fixed submission:
import numpy as np
import math
import sys

sys.setrecursionlimit(1000000)

def contrary_bit(bit):
    if (bit == 1):
        return 0
    elif (bit == 0):
        return 1
    else:
        print("error")

def dfs(adj_lists, nodes, node):
    # nodeから出発して，深さ優先探索
    neighbors = adj_lists[node]
    for neighbor in neighbors:
        if (nodes[neighbor[0]] != -1):
            #訪問済み
            continue
        else:
            if neighbor[1] % 2 == 0:
                # 同じbit  
                nodes[neighbor[0]] = nodes[node]
                nodes = dfs(adj_lists, nodes, neighbor[0])
            else:
                nodes[neighbor[0]] = contrary_bit(nodes[node])
                nodes = dfs(adj_lists, nodes, neighbor[0])
    return nodes

def main():
    N = int(input())
    adj_lists = {}
    for i in range(1, N + 1):
        adj_lists[i] = []
    nodes = [-1] * (N + 1)
    for _ in range(N - 1):
        u, v, w = map(int, input().split())
        adj_lists[u].append((v, w))
        adj_lists[v].append((u, w))
    nodes[1] = 1
    nodes = dfs(adj_lists, nodes, 1)
    ans = nodes[1:]
    for color in ans:
        print(color)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import math

def contrary_bit(bit):
    if (bit == 1):
        return 0
    elif (bit == 0):
        return 1
    else:
        print("error")

def dfs(adj_lists, nodes, node):
    # nodeから出発して，深さ優先探索
    neighbors = adj_lists[node]
    for neighbor in neighbors:
        if (nodes[neighbor[0]] != -1):
            #訪問済み
            continue
        else:
            if neighbor[1] %2 == 0:
                # 同じbit  
                nodes[neighbor[0]]= nodes[node]
                nodes = dfs(adj_lists, nodes, neighbor[0])
            else:
                nodes[neighbor[0]] = contrary_bit(nodes[node])
                nodes = dfs(adj_lists, nodes, neighbor[0])
    return nodes

def main():
    N = int(input())
    adj_lists = {}
    for i in range(1, N + 1):
        adj_lists[i] = []
    # adj_lists = {i: []} # u: [(v, w), []]
    nodes = [-1] * (N + 1)
    for _ in range(N - 1):
        u, v, w = map(int, input().split())
        adj_lists[u].append((v, w))
        adj_lists[v].append((u, w))
    nodes[1] = 1
    nodes = dfs(adj_lists, nodes, 1)
    ans = nodes[1:]
    for color in ans:
        print(color)

if __name__ == '__main__':
    main()
Problem p02696 (python)

Fixed submission:
a, b, n = map(int, input().split())
x = min(b-1,n)
print((a*x)//b - a*(x//b))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
c = [0]*(n+1)
for x in range(n+2):
  c[x] = (a*x)//b - a*(x//b)
print(max(c))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
c = [0]*(n+1)
for x in range(n+1):
  c[x] = (a*x)//b - a*(x//b)
print(max(c))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
current = 0
c = [0]*(n+1)
for x in range(n+1):
  c[x] = (a*x)//b - a*(x//b)
print(max(c))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
current = 0
c = [0]*(n+1)
for x in range(1,n+1):
  c[x]= (a*x)//b - a*(x//b)
print(max(c))
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())
if x >= a*a*b/2:
   print(math.degrees(math.atan(2/a*(b-x/(a*a)))))
else:
   print(math.degrees(math.atan((a*b*b)/(2*x))))

Buggy submission (verdict: Runtime Error):
import math
a, b, x =map(int, input().split())
if x >= a*a*b/2:
   print( math.degrees(math.tanh(2/a*(b-x/(a*a))))
else:
   print(math.degrees(math.tanh(a*b*b/(2*x))))
Problem p02909 (python)

Fixed submission:
s = input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")

Buggy submission (verdict: Runtime Error):
s = input()
if s=='Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else s == 'Rainy':
    print('Sunny')
Problem p02921 (python)

Fixed submission:
s = input()
t = input()
count = 0
for i in range(3):  
  if s[i] == t[i]:
       count = count+ 1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())  
h=list(map(int, input().split()))
count = 0
max_count = 0
for i in range(n-1):
    if h[i+1] <= h[i]:
        count = count + 1
    else:
        max_count = max(max_count,count)
        count = 0
print(max(max_count,count))

Buggy submission (verdict: Runtime Error):
n=int(input())  
h=list(map(int, input().split()))
count = 0
max_count = 0
for i in range(n-1):
    if h[i+1] < h[i]:
        count = count + 1
    else:
        max_count = max(max_count,count)
        count = 0
print(max(max_count,count))

Buggy submission (verdict: Runtime Error):
n=int(input())  
h=list(map(int, input().split()))
count = 0
max_count = 0
for i in range(n-1):
    if h[i+1] <= h[i]:
        count = count + 1
    elif max_count < count:
        max_count = count
        count = 0
    else:
        count = 0
      
print(max(max_count,count))

Buggy submission (verdict: Runtime Error):
n=int(input())  
h=list(map(int, input().split()))
count = 0
max_count = 0
for i in range(n-1):
    if h[i+1] <= h[i]:
        count = count + 1
    else:
        max_count = max(max_count,count)
        count = 0
print(max(max_count,count))
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(n):
    for j in range(n-i):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            print(i,j,n-i-j)
            break()
print(-1,-1,-1)
Problem p02681 (python)

Fixed submission:
def task(s, t):
    for i in range(0, len(s)):
        if s[i] != t[i]:
            print("No")
            return

    print("Yes")


s = input()
t = input()
task(s, t)

Buggy submission (verdict: Runtime Error):
def rec(c, a, x, n, m, start, states, best, price):

    for i in range(start, n):
        price += c[i]
        states[0] += a[i][0]
        states[1] += a[i][1]
        states[2] += a[i][2]

        if states[0] >= x and states[1] >= x and states[2] >= x and price < best:
            best = price

        if i != n - 1:
            best = rec(c, a, x, n, m, i + 1, states, best, price)

        states[0] -= a[i][0]
        states[1] -= a[i][1]
        states[2] -= a[i][2]
        price -= c[i]

    return best


def task(n, m, x, c, a):
    mx = [0] * n
    for i in range(0, n):
        for j in range(0, m):
            mx[j] += a[i][j]

    for j in range(0, m):
        if mx[j] < x:
            print(-1)
            return

    best = rec(c, a, x, n, m, 0, [0, 0, 0], 1000000, 0)

    print(best)


n, m, x = map(int, input().split())
c = []
a = []
for i in range(0, n):
    values = list(map(int, input().split()))
    c.append(values[0])
    a.append(values[1:])

task(n, m, x, c, a)
Problem p02761 (python)

Fixed submission:

N,M = map(int, input().split())

a_list = [0] * N

uncorrect = 0
changezero = True

for i in range(M):
    s,c = map(int, input().split())
    if s == 1:
        changezero = False 
    if a_list[s-1] == 0:
        a_list[s-1] += c
    else:
        if a_list[s-1] != c:
            uncorrect += 1

if changezero and N >= 2:
    a_list[0] += 1

if uncorrect >= 1:
    print(-1)
elif a_list[0] == 0 and N >= 2:
    print(-1)
else:
    ans = 0
    for i in range(N):
        ans += a_list[i] * (10 ** (N-i-1))

    print(ans)

Buggy submission (verdict: Runtime Error):

N,M = map(int, input().split())

a_list = [0] * N

uncorrect = 0
changezero = True

for i in range(M):
    s,c = map(int, input().split())
    if s == 1:
        zero == False 
    if a_list[s-1] == 0:
        a_list[s-1] += c
    else:
        if a_list[s-1] != c:
            uncorrect += 1

if changezero and N >= 2:
    a_list[0] += 1

if uncorrect >= 1:
    print(-1)
elif a_list[0] == 0 and N >= 2:
    print(-1)
else:
    ans = 0
    for i in range(N):
        ans += a_list[i] * (10 ** (N-i-1))

    print(ans)
Problem p02803 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())

maze = [input() for i in range(h)]

ans = 0
for j in range(h):
    for i in range(w):
        if maze[j][i] == ".":
            cnt = [[0] * w for _ in range(h)] 
            q = deque([(j,i)])
            while q:
                y,x = q.popleft()
                for by,bx in ((0,1),(0,-1),(1,0),(-1,0)):
                    ny = y + by
                    nx = x + bx
                    if 0 <= ny < h and 0 <= nx < w:
                        if maze[ny][nx] == "." and cnt[ny][nx] == 0:
                            q += [(ny,nx)]
                            cnt[ny][nx] += cnt[y][x] + 1
                            ans = max(ans, cnt[ny][nx])
                if y == j and x == i:
                    cnt[y][x] = -1


print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

h, w = map(int, input().split())

maze = [input() for i in range(h)]

ans = 0
INF = 20 * 20 + 1
for j in range(h):
    for i in range(w):
        if maze[j][i] == ".":
            cnt = [[INF] * w for _ in range(h)] 
            cnt[j][i] = 0
            q = deque([(j,i)])
            while q:
                y,x = q.popleft()
                for by,bx in ((0,1),(0,-1),(1,0),(-1,0)):
                    by += y
                    bx += x 
                    if 0 <= by < h and 0 <= bx < w:
                        ct = cnt[y][x] + 1
                        if maze[ny][nx] == "." and ct < cnt[ny][nx]:
                            q += [(by,bx)] 
                            cnt[by][bx] = ct
                            ans = max(ans, cnt[by][bx])

print(ans)
Problem p02817 (python)

Fixed submission:
s,t =input().split()

ans =''

print(ans + t + s)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int, input().split())


if a >= k:
    print('{} {}'.format(a-k,b))

elif (a + b) > k:
    print('0 {}'.format(a+b-k))

elif (a + b) < k:
    print('0 0')
Problem p02995 (python)

Fixed submission:
a, b, c, d  = map(int, input().split())

def divide(n):
    return (b // n) - ((a-1) // n)

def gcd(a,b):
    if ( b==0 ):
        return a
    else:
        return (gcd(b, a%b))

def lcm(x, y):
    return (x * y) // gcd(x, y)

ans = b - a + 1

ans -= divide(c)

ans -= divide(d)

ans += divide(lcm(c,d))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d  = map(int, input().split())

def divide(n):
    return (b // n) - ((a-1) // n)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

ans = b - a + 1

ans -= divide(c)

ans -= divide(d)

ans += divide(lcm(c,d))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d  = map(int, input().split())

def divide(n):
    return (b // n) - ((a-1) // n)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

ans = b - a + 1

ans -= divide(c)

ans -= divide(d)

ans += divide(lcm(c,d))

print(ans)
Problem p03160 (python)

Fixed submission:
N = int(input())

blocks = list(map(int, input().split()))

route = [0] * N

for i in range(N):
    if i == 0:
        continue
    elif i == 1:
        route[1] = abs(blocks[1] - blocks[0]) 

    else:
        first = abs(blocks[i] - blocks[i-1]) + route[i-1]
        second = abs(blocks[i] - blocks[i-2]) + route[i-2]
        route[i] = min(first, second)

print(route[N-1])

Buggy submission (verdict: Runtime Error):
# inputを高速化する。
import sys
import numpy as np

input = sys.stdin.readline

N,K = map(int, input().split())
blocks = list(map(int, input().split()))

route = [0] * N

blocks = np.array(blocks)

for i in range(1, N):
    count = max(0, i-K)
    route[i] = min(route[count:i] + np.abs(blocks[count:i] - blocks[i]))

print(route[-1])
Problem p03164 (python)

Fixed submission:
import numpy as np
 
N, W = map(int, input().split())
WV = np.array([input().split() for _ in range(N)], np.int64)
V = sum(WV[:,1])
dp = np.zeros(V + 1, np.int64)
dp += 10 ** 10
dp[0] = 0
for w, v in WV:
    dp[v:] = np.minimum(dp[v:], dp[:-v] + w)
for v in range(V + 1):
    if dp[v] <= W:
        ans = v
print(ans)

Buggy submission (verdict: Runtime Error):
import  numpy as np

N,W = map(int, input().split())

INF = 1e100

dp = [INF] * (10 ** 5 + 1)
dp = np.array(dp)

dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[:-v] + w , dp[v:])


for v,num in enumerate(dp):
    if num <= W:
        ans = v

print(ans)

Buggy submission (verdict: Runtime Error):
import  numpy as np

N,W = map(int, input().split())

INF = 1e100

dp = [INF] * (10 ** 5 + 1)
dp = np.array(dp)

dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[:-v] + w , dp[v:])


for v,num in enumerate(dp):
    if num <= W:
        ans = v

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
 
N,W = map(int, input().split())
 
dp = [10 ** 10] * N * (10 ** 3)
dp[0] = 0
dp = np.array(dp)
 
 
for i in range(N):
    w,v = map(int, input().split())
    dp[v:] = np.minimum(dp[v:] , dp[:-v] + w)
    dp[:v] = np.minimum(dp[:v] , w)
  
for v in range(V + 1):
    if dp[v] <= W:
        ans = v
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
 
N,W = map(int, input().split())
 
dp = np.zeros(W+1 , np.int64)
 
 
for i in range(N):
    w,v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:] , dp[:-w] + v)
 
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
 
N,W = map(int, input().split())
 
dp = np.zeros(W+1 , np.int64)
 
 
for i in range(N):
    w,v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:] , dp[:-w] + v)
 
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np
 
N,W = map(int, input().split())
 
dp = np.zeros(W+1 , np.int64)
 
 
for i in range(N):
    w,v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:] , dp[:-w] + v)
 
print(dp[-1])
Problem p03565 (python)

Fixed submission:
s = input()[::-1]
t = input()[::-1]
 
def check(c,t):
    if len(c) < len(t):
        return False
    for i in range(len(t)):
        if c[i] != "?" and c[i] != t[i]:
            return False
 
    return True
        
 
i = 0 
Has = False
ans = ""
while i < len(s):
    if (s[i] == "?" or s[i] == t[0]) and not Has:
        if check(s[i:],t):
            Has = True
            ans += t
            i += len(t)
        else:
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
            i += 1
 
    elif s[i] == "?":
        i += 1
        ans += "a"
    else:
        ans += s[i]
        i += 1
 
if Has:
    print(ans[::-1])
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
def check(c,t):
    if len(c) < len(t):
        return False
    for i in range(len(t)):
        if c[i] != "?" and c[i] != t[i]:
            return False

    return True
        

i = 0 
Has = False
ans = ""
while i < len(s):
    if (s[i] == "?" or s[i] == t[0]) and not Has:
        if check(s[i:],t):
            Has = True
            ans += t
            i += len(t)
        else:
            if s[i] == "?":
                ans += "a"
            else:
                ans += s[i]
            i += 1

    elif s[i] == "?":
        i += 1
        ans += "a"
    else:
        ans += s[i]
        i += 1

if Has:
    print(ans[::-1])
else:
    print('UNRESTORABLE')
Problem p03854 (python)

Fixed submission:
s = input()

vocabs = ["dream","dreamer","erase","eraser"]

cnt = 0
t = ""
while cnt <= len(s) - 8:
    if s[cnt] == "d":
        if s[cnt+5] == "d":
            cnt += 5
            t += vocabs[0]
        elif s[cnt+5] == "e":
            if s[cnt+7] == "a":
                cnt += 5
                t += vocabs[0]
            else:
                cnt += 7
                t += vocabs[1]
        else:
            break
    elif s[cnt] == "e":
        if s[cnt+5] == "r":
            cnt += 6
            t += vocabs[3]
        else:
            cnt += 5
            t += vocabs[2]
    else:
        break

if s[cnt:] == vocabs[0]:
    t+= vocabs[0]
elif s[cnt:] == vocabs[1]:
    t+= vocabs[1]
elif s[cnt:] == vocabs[2]:
    t+= vocabs[2]
elif s[cnt:] == vocabs[3]:
    t+= vocabs[3]


if s == t:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s = input()

vocabs = ["dream","dreamer","erase","eraser"]

cnt = 0
t = ""
while cnt <= len(s) - 7:
    if s[cnt] == "d":
        if s[cnt+5] == "d":
            cnt += 5
            t += vocabs[0]
        elif s[cnt+5] == "e":
            if s[cnt+7] == "a":
                cnt += 5
                t += vocabs[0]
            else:
                cnt += 7
                t += vocabs[1]
        else:
            break
    elif s[cnt] == "e":
        if s[cnt+5] == "r":
            cnt += 6
            t += vocabs[3]
        else:
            cnt += 5
            t += vocabs[2]
    else:
        break

if s[cnt:] == vocabs[0]:
    t+= vocabs[0]
elif s[cnt:] == vocabs[1]:
    t+= vocabs[1]
elif s[cnt:] == vocabs[2]:
    t+= vocabs[2]
elif s[cnt:] == vocabs[3]:
    t+= vocabs[3]


if s == t:
    print("YES")
else:
    print("NO")
Problem p02664 (python)

Fixed submission:
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

s = input()
ans =""
if len(s)==1:
    if s[0]=="?":
        print("D")
        sys.exit()
    else:
        print(s[0])
        sys.exit()

if s[0]=="?":
    if s[1]=="D" or s[1]=="?":
        ans = ans+"P"
    else:
        ans = ans + "D"
else :
    ans = ans + s[0]

for i in range(1,len(s)):
    if s[i]=="?":
        if ans[i-1]=="P":
            ans = ans + "D"
        elif ans[i-1]=="D":
            if i<len(s)-1:
                if s[i+1]=="P":
                    ans = ans + "D"
                else:
                    ans= ans + "P"
            else:
                ans = ans + "D"
        else:
            ans = ans + "P"    
    else:
        ans = ans + s[i]
    

print(ans)

Buggy submission (verdict: Runtime Error):
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

s = input()
ans =""
if len(s)==1:
    if s[0]=="?":
        print("D")
        sys.exit()
    else:
        print(s[0])
        sys.exit()

if s[0]=="?":
    if s[1]=="D" or s[1]=="?":
        ans = ans+"P"
    else:
        ans = ans + "D"
else :
    ans = ans + s[0]

for i in range(1,len(s)):
    if s[i]=="?":
        if ans[i-1]=="P":
            ans = ans + "D"
        elif ans[i-1]=="D":
            if i<len(s):
                if s[i+1]=="P":
                    ans = ans + "D"
                else:
                    ans= ans + "P"
            else:
                ans = ans + "P"
        else:
            ans = ans + "P"    
    else:
        ans = ans + s[i]
    

print(ans)

Buggy submission (verdict: Runtime Error):
import sys


#torf = [[None for _ in range(m)]for _ in range(n)]
#print(torf)
#print(torf[0][0])
#print(torf[1][0])

s = input()
ans =""

if s[0]=="?":
    if s[1]=="D":
        ans = ans+"P"
    else:
        ans = ans + "D"
else :
    ans = ans + s[0]

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

print(ans)