Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

N=int(input().strip())
A = list(map(int, input().strip().split()))

MOD=10**9+7

ans=0
for i in range(60):
    count1=0
    count0=0
    for j in range(N):
        if A[j]>>i & 1:
            count1+=1
        else:
            count0+=1
    ans+=count0*count1%MOD*pos(2,i,MOD)
    ans%=MOD
print(ans)

Fixed submission:
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

N=int(input().strip())
A = list(map(int, input().strip().split()))

MOD=10**9+7

ans=0
for i in range(60):
    count1=0
    count0=0
    for j in range(N):
        if A[j]>>i & 1:
            count1+=1
        else:
            count0+=1
    ans+=count0*count1%MOD*pos(2,i,MOD)
    ans%=MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input().strip())
A = list(map(int, input().strip().split()))

MOD=10**9+7

ans=0
for i in range(60):
    count1=0
    count0=0
    for j in range(N):
        if A[j]>>i & 1:
            count1+=1
        else:
            count0+=1
    ans+=count0*count1%MOD*2**i%MOD
    ans%=MOD
print(ans)

Fixed submission:
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

N=int(input().strip())
A = list(map(int, input().strip().split()))

MOD=10**9+7

ans=0
for i in range(60):
    count1=0
    count0=0
    for j in range(N):
        if A[j]>>i & 1:
            count1+=1
        else:
            count0+=1
    ans+=count0*count1%MOD*pos(2,i,MOD)
    ans%=MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input().strip())
A = list(map(int, input().strip().split()))

MOD=10**9+7

ans=0
for i in range(N-1):
    for j in range(i,N):
        ans+=A[i] ^ A[j] #XOR
        ans%=MOD
print(ans)


Fixed submission:
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

N=int(input().strip())
A = list(map(int, input().strip().split()))

MOD=10**9+7

ans=0
for i in range(60):
    count1=0
    count0=0
    for j in range(N):
        if A[j]>>i & 1:
            count1+=1
        else:
            count0+=1
    ans+=count0*count1%MOD*pos(2,i,MOD)
    ans%=MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
# import numpy as np
#N=int(input().strip())
#x=[0]*N
#y=[0]*N
#
#for i in range(N):
#    x[i],y[i]=list(map(int,input().strip().split()))

import sys

def power_l(x,power): # for mod
    if power==0:
        return 1
    elif power<0:
        print('error')
        sys.exit(1)
    res = 1
    sq = x%mod
    while(power>0):
        if power&1 > 0:
            res*=sq
            res=res%mod
        sq = sq**2 %mod
        power = power >> 1
    return res%mod

def inv(x): # x^(-1)=x^(p-2) mod
    ans = power_l(x,mod-2)
    return ans
##########################
mod = 10**9+7

X, Y = list(map(int,input().strip().split()))

if (X+Y)%3 !=0:
    print(0)
    sys.exit()
m = (2*X-Y)//3
n = X-2*m

# compute m+nCm=(m+n)!/(m!n!)
# make factorial
f=[1]
for i in range(m+n-1):
    f.append((f[i]*(i+2))%mod)

denom = (f[m-1]*f[n-1])%mod

ans=(f[m+n-1] * inv(denom)) %mod
print(ans)



Fixed submission:
# import numpy as np
#N=int(input().strip())
#x=[0]*N
#y=[0]*N
#
#for i in range(N):
#    x[i],y[i]=list(map(int,input().strip().split()))

import sys

def power_l(x,power): # for mod
    if power==0:
        return 1
    elif power<0:
        print('error')
        sys.exit(1)
    res = 1
    sq = x%mod
    while(power>0):
        if power&1 > 0:
            res*=sq
            res=res%mod
        sq = sq**2 %mod
        power = power >> 1
    return res%mod

def inv(x): # x^(-1)=x^(p-2) mod
    ans = power_l(x,mod-2)
    return ans
##########################
mod = 10**9+7

X, Y = list(map(int,input().strip().split()))

if (X+Y)%3 !=0:
    print(0)
    sys.exit()
m = int((2*X-Y)//3)
n = int(X-2*m)

if m<0 or n<0:
    print(0)
    sys.exit()

# compute m+nCm=(m+n)!/(m!n!)
# make factorial
f=[1,1]
for i in range(m+n-1):
    f.append((f[i+1]*(i+2))%mod)

denom = (f[m]*f[n])%mod

ans=(f[m+n] * inv(denom)) %mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N=int(input().strip())
A=np.array(list(map(int,input().strip().split())))
for i in range(N):
    print(np.argsort(A)[i]+1,end=" ")


Fixed submission:
import numpy as np
N=int(input().strip())
A=np.array(list(map(int,input().strip().split())))
ans=[0]*N
for i in range(N):
    ans[A[i]-1]=i+1
for i in range(N):
    print(ans[i], end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().strip().split())
# A=[0]*Q
score=[K]*N
for i in range(Q):
    A=int(input().strip())
    score[A-1]+=1
    score=list(map(lambda x: x-1,score))

for i in range(N):
    if score[i]>0:
        print("Yes")
    else:
        print("No")

Fixed submission:
N, K, Q = map(int, input().strip().split())
# A=[0]*Q
score=[K]*N
for i in range(Q):
    A=int(input().strip())
    score[A-1]+=1
score=list(map(lambda x: x-Q,score))

for i in range(N):
    if score[i]>0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().strip().split())
# A=[0]*Q
score=[K]*N
for i in range(Q):
    A=int(input().strip())
    score[A-1]+=1
    score=list(map(lambda x: x-1,score))

for i in range(N):
    if score[i]>0:
        print("Yes")
    else:
        print("No")

Fixed submission:
N, K, Q = map(int, input().strip().split())
# A=[0]*Q
score=[K]*N
for i in range(Q):
    A=int(input().strip())
    score[A-1]+=1
score=list(map(lambda x: x-Q,score))

for i in range(N):
    if score[i]>0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().strip().split())
# A=[0]*Q
score=[K]*N
for i in range(Q):
    A=int(input().strip())
    for j in range(N):
        if j==A-1:
            continue
        else:
            score[j]-=1

for i in range(N):
    if score[i]>0:
        print("Yes")
    else:
        print("No")

Fixed submission:
N, K, Q = map(int, input().strip().split())
# A=[0]*Q
score=[K]*N
for i in range(Q):
    A=int(input().strip())
    score[A-1]+=1
score=list(map(lambda x: x-Q,score))

for i in range(N):
    if score[i]>0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N = int(input().strip())
a = [list(map(lambda x: int(x)*(-1), input().split())) for i in range(N)]

for i in range(N):
    tmp=a[:i]+a[i+1:]
    heapq.heapify(tmp)
    ans=heapq.heappop(tmp)[0]*(-1)
    print(ans)

Fixed submission:
N = int(input().strip())
a = [int(input().strip()) for i in range(N)]

a_s=sorted(a,reverse=True)
mx=a_s[0]
for i, val in enumerate(a):
    if val!=mx:
        print(mx)
    else:
        print(a_s[1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input().strip())
a = [list(map(int, input().split())) for i in range(N)]

for i in range(N):
    tmp=a[:i]+a[i+1:]
    print(max(tmp)[0])

Fixed submission:
N = int(input().strip())
a = [int(input().strip()) for i in range(N)]

a_s=sorted(a,reverse=True)
mx=a_s[0]
for i, val in enumerate(a):
    if val!=mx:
        print(mx)
    else:
        print(a_s[1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().strip().split())
h = list(map(int, input().strip().split()))

dp=[10**9]*n

dp[0]=0
for i in range(n):
    # for j in range(1,k+1):
    #     if i+j>n-1:
    #         break
    for j in range(1,min(k+1,n-i)):
        dp[i+j]=min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])

Fixed submission:
n, k = map(int, input().strip().split())
h = list(map(int, input().strip().split()))

dp=[10**9]*n

dp[0]=0
for i in range(n):
    # for j in range(1,k+1):
    #     if i+j>n-1:
    #         break
    for j in range(1,min(k+1,n-i)):
        dp[i+j]=min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().strip().split())
h = list(map(int, input().strip().split()))

dp=[10**9]*n

dp[0]=0
for i in range(n):
    for j in range(1,k+1):
        if i+j>n-1:
            break
        dp[i+j]=min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])

Fixed submission:
n, k = map(int, input().strip().split())
h = list(map(int, input().strip().split()))

dp=[10**9]*n

dp[0]=0
for i in range(n):
    # for j in range(1,k+1):
    #     if i+j>n-1:
    #         break
    for j in range(1,min(k+1,n-i)):
        dp[i+j]=min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
sum=0
K=int(input())+1
r=1
for a in range(1,K):
  for b in range(1,K):
    p=a
    q=b
    if p%q==0:
      r=q
    while p%q!=0:
      r=p%q
      p=q
      q=r
    ab=r
    for c in range(1,K):
      p=c
      q=ab
      if p%q==0:
        r=q
      while p%q!=0:
        r=p%q
        p=q
        q=r
      sum+=r
print(sum)

Fixed submission:
import math
sum=0
K=int(input())+1
for a in range(1,K):
  for b in range(1,K):
    ab=math.gcd(a,b)
    for c in range(1,K):
      sum+=math.gcd(ab,c)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
sum=0
K=int(input())+1
r=1
for a in range(1,K):
  for b in range(1,K):
    for c in range(1,K):
      p=a
      q=b
      if p%q==0:
        r=q
      while p%q!=0:
        r=p%q
        p=q
        q=r
      
      p=r
      q=c
      if p%q==0:
        r=q
      while p%q!=0:
        r=p%q
        p=q
        q=r
      sum+=r
print(sum)

Fixed submission:
import math
sum=0
K=int(input())+1
for a in range(1,K):
  for b in range(1,K):
    ab=math.gcd(a,b)
    for c in range(1,K):
      sum+=math.gcd(ab,c)
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import math
sum=0
K=int(input())+1
for a in range(1,K):
  for b in range(1,K):
    for c in range(1,K):
      sum+=math.gcd(math.gcd(a,b),c)
print(sum)

Fixed submission:
import math
sum=0
K=int(input())+1
for a in range(1,K):
  for b in range(1,K):
    ab=math.gcd(a,b)
    for c in range(1,K):
      sum+=math.gcd(ab,c)
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S= [input() for i in range(N)]
A=list(set(S))
M=len(A)
c=[0]*M

for i in range(M):
  #print(A[i],S.count(A[i]))
  c[i]=S.count(A[i])
#print(A)
#print(c)
max=0
for i in range(M):
  if max<=c[i]:
    max=c[i]
maxS=[]
for i in range(M):
  if max==c[i]:
    maxS.append(A[i])
print(*sorted(maxS),sep='\n')

Fixed submission:
N=int(input())
S= [input() for i in range(N)]
from collections import Counter
c = Counter(S)
d = c.most_common()

max=d[0][1]

A=[]
for i in d:
  if i[1]==max:
    A.append(i[0])
print(*sorted(A),sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())

A=list(input().split())

flag=1
for i in range(N-1):
  if A.count(A[i])>1:
    flag=0
if flag==1:
  print('YES')
else:
  print('NO')




Fixed submission:
N= int(input())

A=sorted(list(input().split()))
flag=1
for i in range(N-1):
  if A[i]==A[i+1]:
    flag=0
    break
if flag==1:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())

H=list(map(int,input().split()))
H=sorted(H)[::-1]

if K>=N:
  print(0)
else:
  for i in range(K):
    del H[0]
  print(sum(H))


Fixed submission:
N,K = map(int,input().split())

H=list(map(int,input().split()))
H=sorted(H)

sum=0
if K>=N:
  print(sum)
else:
  for i in range(N-K):
    sum=sum+H[i]
  print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))

for i in range(N):
  print(A.index(i+1)+1,end=' ')

Fixed submission:
N=int(input())
A=list(map(int, input().split()))

d={}
for i in range(N):
  d[i]=A[i]
  
#print(A)  
#print(d)
#print(sorted(d.items(), key=lambda x:x[0]))
#print(sorted(d.items(), key=lambda x:x[1]))
ans=sorted(d.items(), key=lambda x:x[1])
for i in range(N):
  print(ans[i][0]+1,end=' ')
Buggy python submission (verdict: Runtime Error):
S = input()

N=len(S)
flag=1

for i in range(N//2):
  if S[i*2]=='L':
    flag=0
  if S[i*2+1]=='R':
    flag=0

if S[(i+1)*2]=='L':
  flag=0

if flag==1 :
  print('Yes')
else:
  print('No')
    
    
  

Fixed submission:
S = input()

N=len(S)
flag=1

for i in range(N):
  if i%2==0 and S[i]=='L':
    flag=0
  elif i%2==1 and S[i]=='R':
    flag=0

print('Yes' if flag==1 else 'No')
Buggy python submission (verdict: Runtime Error):
S,T = input().split()

count=0

for i in range(3):
    if S[i]==T[i]:
      count=count+1
print(count)

Fixed submission:
S= input()
T= input()
count=0

for i in range(3):
    if S[i]==T[i]:
      count=count+1
print(count)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())

i=0
#桁数
while 10**i<N:
  i=i+1
    


if i==1:
  num=N
elif i==2:
  num=9
elif i==3:
  num=9+N-99
elif i==4:  
  num=9+999-99
elif i==5:  
  num=9+900+N-10000

print(num)

  

Fixed submission:
import math

N = int(input())

i=0
num=0

#桁数
while 10**i <= N:
  i=i+1
    


if i==1:
  num=N
elif i==2:
  num=9
elif i==3:
  num=9+N-99
elif i==4:  
  num=9+999-99
elif i==5:  
  num=9+900+N-9999
elif i==6:  
  num=9+900+99999-9999
  
print(num)
Buggy python submission (verdict: Runtime Error):
b = input()

if b=='A':
  print('T')
  
elif b=='G':
  print(C')
  
elif b=='T':
  print('A')
elif b=='C':
  print('G') 

Fixed submission:
b = input()

if b=='A':
  print('T')
  
elif b=='G':
  print('C')
  
elif b=='T':
  print('A')
elif b=='C':
  print('G')
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

C=[]
for i in range(1,B):
  if A%i==0 and B%i==0:
    C.append(i)

#print(C)
print(C[-K])
  



Fixed submission:
A,B,K = map(int,input().split())

C=[]
for i in range(1,101):
  if A%i==0 and B%i==0:
    C.append(i)

#print(A,B,K)
#print(C)
print(C[-K])

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

C=[]
for i in range(1,B):
  if A%i==0 and B%i==0:
    C.append(i)

print(C)
print(C[-K])
  

Fixed submission:
A,B,K = map(int,input().split())

C=[]
for i in range(1,101):
  if A%i==0 and B%i==0:
    C.append(i)

#print(A,B,K)
#print(C)
print(C[-K])

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

C=[]
for i in range(1,A):
  if A%i==0 and B%i==0:
    C.append(i)

#print(C)
print(C[-K])
  

Fixed submission:
A,B,K = map(int,input().split())

C=[]
for i in range(1,101):
  if A%i==0 and B%i==0:
    C.append(i)

#print(A,B,K)
#print(C)
print(C[-K])
Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input().split())

print(max(A,B,C)*9+A+B+C)  
  
  

Fixed submission:
A,B= map(int,input().split())

if (A*B)%2!=0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())

a =[list(input()) for i in range(W)]

i=0
rm=0
for i in range(H):
  if a[i].count('#')==0:
    k=i
    for j in range(H-k-1):
      a[k+j]=a[k+j+1]
    H=H-1
    
for j in range(W):
  flag=1
  for i in range(H):
    #print(i,j,a[i][j])
    if a[i][j]=='#':
      flag=flag*0
  if flag==1:
    for i in range(H):
      a[i][j]='-' 
    W=W-1

for i in range(H) :
  if a[i].count('-')!=0:
    a[i].remove('-')
  
ans=list('' for i in range(W))

N=len(a[0])

for i in range(H):
  for j in range(N):
    ans[i]=ans[i]+a[i][j]
    
for i in range(H):
  print(ans[i])

Fixed submission:
H,W=map(int,input().split())

A = [list(input()) for i in range(H)]

l=[False]*H
c=[False]*W

for i in range(H):
  for j in range(W):
    if A[i][j]=='#':
      l[i]=True
      c[j]=True

ans=['' for i in range(H)]
for i in range(H):
  for j in range(W):
    if l[i] and c[j]:
      ans[i]+=A[i][j]
for i in range(H):
  if str(ans[i])!='':
    print(str(ans[i]))
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

if K>B-A-1:
  K=B-A
  
ans=[]
for i in range(K):
  ans.append(A+i)
for i in range(B-K,B):
  ans.append(i+1)
#print(ans)

n=len(ans)
print(ans[0])
for i in range(1,n):
  if ans[i]!=ans[i-1]:
    print(ans[i])
  

Fixed submission:
A,B,K = map(int,input().split())

if A+K-1< B-K+1:
  for i in range(A,A+K):
    print(i)
  for i in range(B-K+1,B+1):
    print(i)
elif A+K-1>= B-K+1:
  for i in range(A,B+1):
    print(i)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

if K>B-A:
  K=B-A
  
ans=[]
for i in range(K):
  ans.append(A+i)
for i in range(B-K,B):
  ans.append(i+1)
#print(ans)

n=len(ans)
print(ans[0])
for i in range(1,n):
  if ans[i]!=ans[i-1]:
    print(ans[i])
  

Fixed submission:
A,B,K = map(int,input().split())

if A+K-1< B-K+1:
  for i in range(A,A+K):
    print(i)
  for i in range(B-K+1,B+1):
    print(i)
elif A+K-1>= B-K+1:
  for i in range(A,B+1):
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
import math

A = []
B = []
for i in range(N):
  a, b = map(int,input().split())
  A.append(int(a))
  B.append(int(b))

count=0
for i in range(N):
  #print(i,A[N-1-i],B[N-1-i])
  if A[N-1-i]%B[N-1-i]==0:
    n=0
  elif A[N-1-i]>B[N-1-i]:
    n=math.ceil(A[N-1-i]/B[N-1-i])*B[N-1-i]-A[N-1-i]
  elif A[N-1-i]<B[N-1-i]:
    n= B[N-1-i]-A[N-1-i]
  count +=n
  #print(n)
  for j in range(N-i):
    A[j]+=n
  #print(A) 
  #print(B) 
print(count)

Fixed submission:
N = int(input())
import math

A = []
B = []
for i in range(N):
  a, b = map(int,input().split())
  A.append(int(a))
  B.append(int(b))

n=0
for i in range(N):
  #print(i,A[N-1-i]+n,B[N-1-i]+n)
  
  if (A[N-1-i]+n)%(B[N-1-i])==0:
    n+=0
  elif A[N-1-i]+n>B[N-1-i]:
    n+=math.ceil((A[N-1-i]+n)/B[N-1-i])*(B[N-1-i])-A[N-1-i]-n
    #print('!',n,math.ceil((A[N-1-i]+n)/(B[N-1-i])))
  elif A[N-1-i]+n<B[N-1-i]:
    n+= B[N-1-i]-A[N-1-i]-n
  #print(n)  
    
  #count +=n
  #print(n)
  #for j in range(N-i):
    #A[j]+=n

print(n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > t:
        print(-1)
        exit(0)

prin(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > t:
        print(-1)
        exit(0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 1
t = 1e18
for i in range(n//2):
    ans *= a[i]
    ans *= a[i+n//2]

if n % 2 == 1:
    ans *= a[n-1]

if ans <= t:
    print(ans)
else:
    print(-1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > t:
        print(-1)
        exit(0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 1
t = 10 ** 18
for i in range(n):
    if a[i] == 0:
        print(0)
        exit(0)
    ans *= a[i]

if ans <= t:
    print(ans)
else:
    print(-1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > t:
        print(-1)
        exit(0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in range(n):
    ans *= a[i]

if ans <= 10 ** 18:
    print(ans)
else:
    print(-1)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = 1
t = 1e18
if 0 in a:
    print(0)
    exit(0)

for i in range(n):
    ans *= a[i]
    if ans > t:
        print(-1)
        exit(0)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
t = input()
ans = []

for i in range(len(t) - 1, -1, -1):
    if t[i] == '?' and i == len(t) - 1:
        ans.insert(0, 'D')
        continue
    if t[i] == '?':
        if ans[0] == 'D':
            ans.insert(0, 'P')
        else:
            ans.insert(0, 'D')
    else:
        ans.insert(0, t[i])

print(''.join(ans))


Fixed submission:
t = input()
ans = []

for i in range(len(t)):
    ans.append(t[i])

for i in range(len(t)):
    if ans[i] == '?':
        ans[i] = 'D'
print(''.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
x = int(input())

remain = x % 100
quotient = math.floor(x/100)

items = [100, 101, 102, 103, 104, 105]
n = 6

for moneys in itertools.product(items, repeat=quotient):
    if sum(moneys) == x:
        print(1)
        exit()
print(0)


Fixed submission:
import itertools
import math
x = int(input())

remain = x % 100
quotient = math.floor(x/100)

items = [100, 101, 102, 103, 104, 105]
n = 6

for moneys in itertools.combinations_with_replacement(items, quotient):
    if sum(moneys) == x:
        print(1)
        exit()
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())

a = []
for i in range(q):
    a.append(int(input()))

point = [k for _ in range(n)]

for i in range(q):
    for j in range(n):
        if a[i] != j:
            point[j - 1] -= 1

for i in range(n):
    if point[i] > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k, q = map(int, input().split())

a = []
for i in range(q):
    a.append(int(input()))

point = [0 for _ in range(n)]

for i in range(q):
    point[a[i] - 1] += 1

for i in range(n):
    if k - q + point[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(m):
    max = 0
    for j in range(n):
        if max < a[j]:
            max = a[j]
            max_i = j
    a[max_i] = math.floor(a[max_i] / 2)
###    a[a.index(max(a))] = math.floor(a[a.index(max(a))] / 2)

print(sum(a))

Fixed submission:
import heapq


n, m = map(int, input().split())
a = [-int(x) for x in input().split()]

heapq.heapify(a)

for i in range(m):
    t = -heapq.heappop(a)
    heapq.heappush(a, (t // 2) * (-1))

print(-sum(a))

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(m):
    max = 0
    for j in range(n):
        if max < a[j]:
            max = a[j]
            max_i = j
    a[max_i] = math.floor(a[max_i] / 2)
###    a[a.index(max(a))] = math.floor(a[a.index(max(a))] / 2)

print(sum(a))

Fixed submission:
import heapq


n, m = map(int, input().split())
a = [-int(x) for x in input().split()]

heapq.heapify(a)

for i in range(m):
    t = -heapq.heappop(a)
    heapq.heappush(a, (t // 2) * (-1))

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import math

n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(m):
    a[a.index(max(a))] = math.floor(a[a.index(max(a))] / 2)

print(sum(a))

Fixed submission:
import heapq


n, m = map(int, input().split())
a = [-int(x) for x in input().split()]

heapq.heapify(a)

for i in range(m):
    t = -heapq.heappop(a)
    heapq.heappush(a, (t // 2) * (-1))

print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
t = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        t += 1
print(min([n - 1, h + 2 * k]))


Fixed submission:
n, k = map(int, input().split())
s = input()
t = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        t += 1
print(min([n - 1, t + 2 * k]))

Buggy python submission (verdict: Runtime Error):
from fractions import gcd


a, b, c, d = map(int, input().split())
lcm = int(c * d / gcd(c, d))
A = a - 1
l_cd = A - A // c - A // d + A // lcm
r_cd = b - b // c - b // d + b // lcm
print(r_cd - l_cd)


Fixed submission:
n, k = map(int, input().split())
s = input()
t = 0
for i in range(n - 1):
    if s[i] == s[i + 1]:
        t += 1
print(min([n - 1, t + 2 * k]))