Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
 
print(min(a*int(b),b*int(a) ) )


Fixed submission:
a,b=map(int,input().split())
s=sum(map(int,input().split()))
print("Yes" if s>=a else "No")

Buggy python submission (verdict: Runtime Error):
a,b = input().split()
 
print(min(a*int(b),b*int(a) ) )
      


Fixed submission:
a,b=map(int,input().split())
s=sum(map(int,input().split()))
print("Yes" if s>=a else "No")

Buggy python submission (verdict: Runtime Error):
a,b =　input().split()
 
print(min(a*int(b),b*(int(a) ) )

Fixed submission:
a,b=map(int,input().split())
s=sum(map(int,input().split()))
print("Yes" if s>=a else "No")

Buggy python submission (verdict: Runtime Error):
a,b　=　input().split()
 
print(min(a*int(b),b*(int(a)))

Fixed submission:
a,b=map(int,input().split())
s=sum(map(int,input().split()))
print("Yes" if s>=a else "No")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=sum(map(int,input().split()))
print("Yes" ifs>=a else "No")

Fixed submission:
a,b=map(int,input().split())
s=sum(map(int,input().split()))
print("Yes" if s>=a else "No")
Buggy python submission (verdict: Runtime Error):
a, b=input().split()
 
print(min(a＊(int(b)),b＊(int(a) ) )


Fixed submission:
N,M=map(int,input().split())
print("Yes" if N==M else "No")

Buggy python submission (verdict: Runtime Error):
a, b=input().split()
 
print(min(a*(int(b)),b*(int(a) ) )

Fixed submission:
N,M=map(int,input().split())
print("Yes" if N==M else "No")

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
 
print(min(a*int(b),b*(int(a) ) )
      


Fixed submission:
N,M=map(int,input().split())
print("Yes" if N==M else "No")

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
print(min(a*int(b),b*(int(a))) 


Fixed submission:
N,M=map(int,input().split())
print("Yes" if N==M else "No")
Buggy python submission (verdict: Runtime Error):
a,b　=　input().split()
 
print(min(a*int(b),b*(int(a) ) )

Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a, b=input().split()
 
print(min(a＊(int(b)),b＊(int(a) ) )


Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a, b=input().split()
 
print(min(a*(int(b)),b*(int(a) ) )


Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
 
print(min(a＊int(b),b＊(int(a) ) )

Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
 
print(min(a＊int(b),b＊(int(a) ) )
      


Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
 
print(min(a*int(b),b*(int(a) ) )
      


Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=input().split()

print(min(a*int(b),b*(int(a)))

Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
print(min(a*int(b),b*(int(a))) 


Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
print( min(a*int(b), b*(int(a) ) ) 

Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
print( min (a*(int(b), b*(int(a) ) ) 


Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
print(min(a*(int(b),b*(int(a)))))


Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )

Buggy python submission (verdict: Runtime Error):
a,b=map(int.input().split())
print(b**a if b>=a else a**b)

Fixed submission:
a, b = input().split()
 
print(min(a*int(b), b*int(a) ) )
Buggy python submission (verdict: Runtime Error):
n,k,m=map(int,input().split())
a=list((map(int,input(),split()))
ans=max(0,n*m-sum(a))
print(ans if n*m-s<=k else -1)


Fixed submission:
c=input()
print(chr(ord(c)+1))

Buggy python submission (verdict: Runtime Error):
c=input()
print(chr(ord(c)+1)

Fixed submission:
c=input()
print(chr(ord(c)+1))
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
print(6-(A+B))

Fixed submission:
a=int(input())
b=int(input())
print(6-a-b)

Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
print(6-(a+B))

Fixed submission:
a=int(input())
b=int(input())
print(6-a-b)
Buggy python submission (verdict: Runtime Error):
days=["SUN","MON","TUE","WED","THR","FRI","SAT"]
print(7-days.index(input()))

Fixed submission:
days=["SUN","MON","TUE","WED","THU","FRI","SAT"]
print(7-days.index(input()))
Buggy python submission (verdict: Runtime Error):
a=input()
print(a**2)

Fixed submission:
A=int(input())
print(A**2)
Buggy python submission (verdict: Runtime Error):
weather=["Sunny","Cloudy","Rainy"]
print(weather[1+weather.index(input())]

Fixed submission:
weather=["Rainy","Cloudy","Sunny"]
print(weather[-1+weather.index(input())])

Buggy python submission (verdict: Runtime Error):
weather=["Sunny","Cloudy","Rainy"]
print(chr(1+(weather.index(input))))

Fixed submission:
weather=["Rainy","Cloudy","Sunny"]
print(weather[-1+weather.index(input())])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
k=(a+b)//2
print(k if ((a>=k and b<=k) or (a<=K and b>=k)) and k%2==0 else "IMPOSSIBLE")

Fixed submission:
a,b=map(int,input().split())
print((a+b)//2 if (a+b)%2==0 else "IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
k=(a+b)/2
print(k if ((a>=k and b<=k) or (a<=K and b>=k)) and k%2==0 else "IMPOSSIBLE")

Fixed submission:
a,b=map(int,input().split())
print((a+b)//2 if (a+b)%2==0 else "IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
print(input（）.count('1'))


Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
print(input（）.count('1'))



Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
print(input.count('1'))



Fixed submission:
print(input().count("1"))
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
x = int(input())
y = int(input())

D = int(input())
distance = math.sqrt(x**2 + y**2)

count = 0
for i in range(1, N+1):
    if distance <= D:
        count += 1

print(count)

Fixed submission:
import math
N, D = map(int, input().split()) #split()で空白区切り
count = 0
for i in range(N):
    x, y = map(int, input().split())
    if math.sqrt(x**2 + y**2) <= D:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1,N+1):
    ans += int(i*(1+N//i)*(N//i)/2)
print(ans)

Fixed submission:
N = int(input())
c = (N+1)//2
ans = 0
for i in range(1,N-c+1):
    ans += i*(1+N//i)*(N//i)/2
ans += N*c -(c-1)*c/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
ans = 1
if abs(N-M) >= 2:
  print(0)
elif abs(N-M) == 1:
  for i in range(1,min(N,M)+1):
    ans *= i
    ans = ans % (10**9 + 7)
  ans = ans**2 * max(N,M)
  ans = ans % (10**9 + 7)
  print(ans)
elif abs(N-M) == 0:
  for i in range(1,N+1):
    ans *= i
    ans = ans % (10**9 + 7)
  ans = ans**2
  ans *= 2
  ans = ans % (10**9 + 7)
  print(ans)

Fixed submission:
N,M = map(int,input().split())
ans = 1
if abs(N-M) >= 2:
  print(0)
elif abs(N-M) == 1:
  for i in range(1,min(N,M)+1):
    ans *= i
    ans = ans % (10**9 + 7)
  ans = ans**2 * max(N,M)
  ans = ans % (10**9 + 7)
  print(ans)
elif abs(N-M) == 0:
  for i in range(1,N+1):
    ans *= i
    ans = ans % (10**9 + 7)
  ans = ans**2
  ans *= 2
  ans = ans % (10**9 + 7)
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
sum=0

while N > 0:
    sum += N % 10
    N //= 10

if sum % 9 == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
N = int(input())

if sum(list(map(int, str(N)))) % 9 ==0:
    print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
A, B, T = map(int, input().split())
print(((T+0.5)//B)*a)

Fixed submission:
A, B, T = map(int, input().split())
print(int(((T+0.5)//A)*B))
Buggy python submission (verdict: Runtime Error):
input()
A = list(map(int, input().split()))
count == 0
while all(a % 2 == 0 for a in A)
	A == [a/2 for a in A]
  	count += 1
print(count)

Fixed submission:
input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if n%2 == 1:
  a.append(1)
  n += 1

for num in range(int(n/2)):
  product *= int(a[num]) * int(a[n - 1 - num])

if product > level:
  print("-1")
else:
  print(product)

Fixed submission:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if "0" in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
a= input().split()
level = np.power(10, 18)
product = 1

for num in range(n):
  product *= int(a[num])

if product > level:
  print("-1")
else:
  print(product)

Fixed submission:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if "0" in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a= input().split()
level = 1000000000000000000
product = 1

for num in range(n):
  product *= int(a[num])

if product > level:
  print("-1")
else:
  print(product)

Fixed submission:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if "0" in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

for num in range(n):
  product *= int(a[num])

if product > level:
  print("-1")
else:
  print(product)

Fixed submission:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if "0" in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

for num in range(n):
  product *= int(a[num])

if product > level:
  print("-1")
else:
  print(product)

Fixed submission:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if "0" in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

for num in range(n):
  product *= int(a[num])

if product > level:
  print("-1")
else:
  print(product)

Fixed submission:
n = int(input())
a= input().split()
level = pow(10, 18)
product = 1

if "0" in a:
  print(0)
else:
  for num in range(n):
    product *= int(a[num])
    if product > level:
      print("-1")
      break
  if product <= level:
    print(product)
Buggy python submission (verdict: Runtime Error):
if a >=0 and b>=0 :
    if a+v*t >= b+ w*t:
        print("YES")
    else:
        print("NO")
elif a < 0 and b >= 0 :
    if -a+v*t >= b + w*t:
        print("YES")
    else :
        print("NO")
else :
    if v*t - w*t >= -(a-b):
        print("YES")
    else :
        print("NO")

Fixed submission:
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if a >=0 and b>=0 :
    if a+v*t >= b+ w*t:
        print("YES")
    else:
        print("NO")
elif a <0 and b >=0:
    if a+v*t >= b + w*t:
        print("YES")
    else :
        print("NO")
else :
    if -a+v*t >= -b + w*t:
        print("YES")
    else:
        print("NO")
Buggy python submission (verdict: Runtime Error):
a=int(print())
b=print(a[-1])
if b == 3:
  print(a+"bon")
elif b ==0 or 1 or 6 or 8:
  print(a+"pon")
else :
  print(a+"hon")

Fixed submission:
a=input()
b=(a[-1])
if b == "3":
  print("bon")
elif b == "0" or b =="1" or b =="6" or b =="8":
  print("pon")
else :
  print("hon")
Buggy python submission (verdict: Runtime Error):
a, b, c,k = map(int,input().split())

if a + b >= k :
    print(a)
elif a > k :
    print(k)
else :

    print(2*a - k + b)


Fixed submission:
n=input()
m=input()

M=(m[:-1])
if n ==M :
  print("Yes")
else : 
  print("No")
Buggy python submission (verdict: Runtime Error):
a, b, c, x = list(map(int,input().split()))
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans) 

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import functools
import operator

N, K = [int(x) for x in input().split()]

arr = [int(x) for x in input().split()]

#print(arr)

mx_list = []

for x in itertools.combinations(arr, K):
    #print(x)
    mx_list.append(functools.reduce(operator.mul,x))

mx = max(mx_list)

y = (10**9 + 7)

print(mx % y)

Fixed submission:
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
cnt_plus=0
cnt_zero=0
cnt_minus=0
arr_plus=[]
arr_minus=[]

for i in range(n):
    if arr[i]>0:
        cnt_plus+=1
        arr_plus.append(arr[i])
    elif arr[i]<0:
        cnt_minus+=1
        arr_minus.append(-arr[i])
    else:
        cnt_zero+=1
if cnt_plus+cnt_minus<k: #K個の積の中に0を含む場合、答えは0
    print(0)
    exit()
    
if k==n: #K=Nの場合
    if cnt_zero!=0: #0がひとつでもあれば答えは0
        print(0)
    else:
        ans=1
        for i in range(cnt_plus):
            ans*=arr_plus[i]
            ans%=mod
        for i in range(cnt_minus):
            ans*=arr_minus[i]
            ans%=mod
        if cnt_minus%2==0: #負の数が偶数個であれば積は正
            print(ans)
        else: #そうでなければ積は負となる
            print((-ans)%mod)
    exit()
if cnt_plus==0 and k%2==1: #正の数がないとき
    if cnt_zero!=0: #0がひとつでもあれば答えは0にできる
        print(0)
    else: #0がないときは負の数を絶対値が小さい順に掛けるのが最善
        arr_minus=sorted(arr_minus)
        tmp=1
        for i in range(k):
            tmp*=arr_minus[i]
            tmp%=mod
        print((-tmp)%mod)
    exit()
else: #正の数と負の数から合計K個取れるとき
    arr_plus=sorted(arr_plus,reverse=True)
    arr_minus=sorted(arr_minus,reverse=True)
    if k%2==0: #Kが偶数であれば何もしない
        ans=1
        pos_plus=0
        pos_minus=0
        cnt=0
    else: #Kが奇数であれば正の数から最大のものを取っておき、Kが偶数の場合に帰着させる
        ans=arr_plus[0]
        pos_plus=1
        pos_minus=0
        cnt=1
    while cnt<k:
        cand1=0
        if pos_plus<=cnt_plus-2: #正の数を2つ取れるなら取る
            cand1=arr_plus[pos_plus]*arr_plus[pos_plus+1]      
            cand2=0
        if pos_minus<=cnt_minus-2: #負の数を2つ取れるなら取る:
            cand2=arr_minus[pos_minus]*arr_minus[pos_minus+1]
        if cand1>=cand2: #正の数を2つ取った積のほうが大きい場合
            pos_plus+=2
            ans*=cand1
            ans%=mod
        else: #負の数を2つ取った積のほうが大きい場合
            pos_minus+=2
            ans*=cand2
            ans%=mod
        cnt+=2
    print(ans)
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
height=list(map(int,input().split()))
humidai_list=[0]
total_height=[height[0]]
del height[0]
#リストの要素を消す
for i in height:
    if max(total_height) > i :
        humidai=max(total_height)-i
        humidai_list.append(humidai)
        total_height.append(i+humidai)
    else:
        humidai=0
        humidai_list.append(humidai)
        total_height.append(i)
print(sum(humidai_list))


Fixed submission:
N=int(input())
height=list(map(int,input().split()))
humidai_list=[0]
total_height=[height[0]]
del height[0]
#リストの要素を消す
for i in height:
    if total_height[-1] > i :
        humidai=total_height[-1]-i
        humidai_list.append(humidai)
        total_height.append(i+humidai)
    else:
        total_height.append(i)
print(sum(humidai_list))
Buggy python submission (verdict: Runtime Error):
an=N//1000
ans=(an+1)*1000-N
if an==0:
  print(0)
else:
  print(ans)

Fixed submission:
N=int(input())
an=N//1000
ans=(an+1)*1000-N
if N%1000==0:
  print(0)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
P=list(map(int,input().split()))
P=sorted(P)
ans=0
for i in range(K):
    ans+=P(i)
print(ans)

Fixed submission:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P=sorted(P)
ans=0
for i in range(K):
    ans+=P[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))

def trans(arr):
    result=[]
    for i in range(1,len(arr)+1):
        ans=0
        for j in range(1,len(arr)+1):
            kyori=abs(i-j)
            if kyori<=arr[j-1]:
                ans+=1
            else:
                continue
        result.append(ans)
    arr=result
    return arr

if N<=K:
    ans=[N]*N
    ans=" ".join(map(str,ans))
    print(ans)
else:
    for i in range(K):
        A=trans(A)
    A=" ".join(map(str,A))
    print(A)

Fixed submission:
#素のPythonでは通りませんでしたが，PyPyを使ったら通りました
N, K = map(int, input().split())
As = list(map(int, input().split()))

for i in range(K):
    table = [0 for _ in range(N*2)]
    # imos法 - メモ
    for j in range(N):
        ai = As[j]
        # 電球が照らす左端をメモ
        table[max((j-ai)*2-1, 0)] += 1
        # 電球が照らす右端をメモ
        table[min((j+ai)*2+1, N*2-1)] -= 1
    
    # imos法 - シミュレート
    for j in range(N*2):
        if j > 0:
            table[j] += table[j-1]
    
    # 答えになおす
    for j in range(N):
        As[j] = table[j*2]
    
    exit_condition = True
    for j in range(N):
        if As[j] != N:
            exit_condition = False
            break
    
    if exit_condition:
        print(*As)
        exit(0)
            

print(*As)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=1
for i in range(N):
  ans*=i
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
A,B=map(int,input().split())
print(A* B)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=map(int,input().split())
ans=1
for i in range(N):
  ans*=A[i]
  if ans > 10**18:
    break
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans=1
    for i in range(N):
        ans*=A[i]
        if ans >10**18:
            break
    if ans > 10**18:
      print(-1)
    else:
      print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=map(int,input().split())
ans=1
for i in range(N):
  ans*=A[i]
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans=1
    for i in range(N):
        ans*=A[i]
        if ans >10**18:
            break
    if ans > 10**18:
      print(-1)
    else:
      print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(mao(int,input().split()))
ans=1
for i in range(N):
  ans*=i
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
if 0 in A:
    print(0)
else:
    ans=1
    for i in range(N):
        ans*=A[i]
        if ans >10**18:
            break
    if ans > 10**18:
      print(-1)
    else:
      print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#答え
T=input()

#考えられる要素数total
total=2**T.count("?")
#?の個数
num=T.count("?")

ans=0
ans_str=""
for i in range(total):
    T_trans=""
    #変換後のT
    trans=[]
    #このリストにそって、?をPかDに変換する
    #ここで1がP、0がDとし、格納していく
    ptn = bin(i)[2:].rjust(num, "0")
    for j in range(num):
        if ptn[j]==1:
            trans.append(1)
        else:
            trans.append(0)
    
    for k in T:
        if k=="?":
            if trans[0]==1:
                T_trans+="P"
                del trans[0]
            else:
                T_trans+="D"
                del trans[0]
        else:
            T_trans+=k
    
    n=T_trans.count("D")+T_trans.count("PD")
    if ans<=n:
        ans_str=T_trans
        ans=n
    
print(ans_str)

Fixed submission:
T=input()
T_trans=""
for i in T:
    if i=="?":
        T_trans+="D"
    else:
        T_trans+=i
print(T_trans)

Buggy python submission (verdict: Time Limit Exceeded):
#答え
T=input()

#考えられる要素数total
total=2**T.count("?")
#?の個数
num=T.count("?")

ans=0
ans_str=""
for i in range(total):
    T_trans=""
    #変換後のT
    trans=[]
    #このリストにそって、?をPかDに変換する
    #ここで1がP、0がDとし、格納していく
    ptn = bin(i)[2:].rjust(num, "0")
    for j in range(num):
        if ptn[j]==1:
            trans.append(1)
        else:
            trans.append(0)
    
    for k in T:
        if k=="?":
            if trans[0]==1:
                T_trans+="P"
                del trans[0]
            else:
                T_trans+="D"
                del trans[0]
        else:
            T_trans+=k
    
    n=T_trans.count("D")+T_trans.count("PD")
    if ans<=n:
        ans_str=T_trans
        ans=n
    
print(ans_str)

Fixed submission:
T=input()
T_trans=""
for i in T:
    if i=="?":
        T_trans+="D"
    else:
        T_trans+=i
print(T_trans)
Buggy python submission (verdict: Runtime Error):
#１行目の『N M』の取得
N,M=map(int,input().split())

#2-(M+1)行目の取得
switch_li=[[] for _ in range(M)] 
#M個の入れ子のリスト、スイッチの個数、スイッチ何がついているか
for i in range(M):
    li=list(map(int,input().split()))
    switch_li[i].extend(li)
    #appendではなくてextendを使ってリストを展開してから結合する

#スイッチの個数は正直データとして要らないので消す
#del li[0] で値消せる
for i in range(M):
    del switch_li[i][0]
#これでついているスイッチだけを格納したM列の入れ子リストができた

#M+2行目のPの取得
P=list(map(int,input().split()))

#スイッチのつき方の全探索する
#スイッチはN個あり、それが着くか付かないかで、場合の数は、2**N通り
switch_bit=[[] for _ in range(2**N)]
for i in range(2**N):
    for j in range(N):
        if (i>>j)&1==1:
            switch_bit[i].append(j+1)
        else:
            continue
#これで全ての組み合わせを抽出できた（スイッチonのものだけが記載される）

#switch_bitそれぞれについて条件を満たすのかどうか判定する
#まずスイッチ3で考えてみる(具体的でまず考えた方がわかりやすい)、その後それを一般化する
#switch_li{2}の要素をfor文で回して、スイッチonのものに含まれている場合は、リストに追加する
#それを最後に2で割って値を比べる
#まずスイッチ３のままコード書いてあとでそれを修正する
#今は何かスイッチ光っているものが入力されているとする（ここではswitch_bit[i]とする）
#実際実行することを考えると、iでスイッチ光るものを固定（switch_bit）し、j=3でスイッチを固定して光るかどうか判定する


#スイッチのつく組みが与えられている時に、電球がつくかどうか判定する関数を作る
def light_or_not(x,i):
    li=[]
    for k in switch_li[x-1]:
        if k in switch_bit[i]:
            li.append(k)
        else:
            continue
    if len(li)==0:
        return False
    elif len(li)%2==P[x-1]:
        return True
    else:
        return False
    
ans=0
for i in range(2**N):
    for j in range(1,N+2):
        if j==N+1:
            ans+=1
        elif light_or_not(j,i):
            continue
        else:
            break
print(ans)

Fixed submission:
N, M = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(M)]  #sの各要素のはじめはk
p = list(map(int, input().split()))
ans = 0

# 0をoffとして2進数でパターンを表現

for i in range(2 ** N):
    ptn = bin(i)[2:].rjust(N, "0")  # N桁の2進表現にする,さらに0を足している（左に）
    light = True  # 着目している電球が点灯していないときはこれがFalseになる
    for j in range(M):
        tmp = 0  # 着目している電球について、スイッチのonの個数をカウントする
        for n in range(1, s[j][0] + 1):
            if ptn[s[j][n] - 1] == "1":
                tmp += 1
        if tmp % 2 != p[j] % 2:
            light = False
    if light:
        ans += 1

print(ans)