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

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

tree = {}
N = 0

def assign(assignment, u, prev_color):
    color = 1
    for v in tree[u]:
        if color == prev_color:
            color += 1
        assignment[u,v] = color
        assign(assignment, v, color)
        color += 1

def main():
    global tree, N
    N = int(input())
    tree = {i: [] for i in range(1,N+1)}
    edges = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        edges.append((a, b))
    ans = {}
    assign(ans, 1, None)
    print(max(ans.values()))
    for edge in edges:
        print(ans[edge])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(50000)

tree = {}
N = 0

def assign(assignment, u, prev_color):
    color = 1
    for v in tree[u]:
        if color == prev_color:
            color += 1
        assignment[u,v] = color
        assign(assignment, v, color)
        color += 1

def main():
    global tree, N
    N = int(input())
    tree = {i: [] for i in range(1,N+1)}
    edges = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        edges.append((a, b))
    ans = {}
    assign(ans, 1, None)
    print(max(ans.values()))
    for edge in edges:
        print(ans[edge])

if __name__ == "__main__":
    main()
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def main():
    n, q = map(int, input().split())
    edges = [[] for _ in range(n+1)]

    for a, b in readlines(n-1):
        edges[a].append(b)
        edges[b].append(a)

    counter = [0] * (n+1)
    for q, x in readlines(q):
        counter[q] += x

    def dfs(u, prev):
        for v in edges[u]:
            if v == prev:
                continue
            counter[v] += counter[u]
            dfs(v, u)

    dfs(1, 0)

    print(" ".join(map(str, counter[1:])))

main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import setitem

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def main():
    n, q = map(int, input().split())
    edges = [[] for _ in range(n+1)]

    for a, b in readlines(n-1):
        edges[a].append(b)
        edges[b].append(a)

    counter = [0] * (n+1)
    for q, x in readlines(q):
        counter[q] += x

    def dfs(u, prev):
        for v in edges[u]:
            if v == prev:
                continue
            counter[v] += counter[u]
            dfs(v, u)

    dfs(1, 0)

    print(" ".join(map(str, counter[1:])))

main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import setitem

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def main():
    n, q = map(int, input().split())
    edges = {i: 0 for i in range(n+1)}

    bigroot = False
    for a, b in readlines(n-1):
        if not bigroot and edges[b] > 0:
            edges = {v: k for k, v in edges.items()}
            bigroot = True

        if bigroot:
            edges[a] = b
        else:
            edges[b] = a

    counter = [0] * (n+1)

    for q, x in readlines(q):
        counter[q] += x

    iterator = range(n, 0, -1) if bigroot else range(1, n+1)
    for i in iterator:
        parent = edges[i]
        counter[i] += counter[parent]

    print(" ".join(map(str, counter[1:])))

main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import setitem

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def main():
    n, q = map(int, input().split())
    edges = {i: 0 for i in range(n+1)}

    bigroot = False
    for a, b in readlines(n-1):
        if not bigroot and edges[b] > 0:
            edges = {v: k for k, v in edges.items()}
            bigroot = True

        if bigroot:
            edges[a] = b
        else:
            edges[b] = a

    counter = [0] * (n+1)

    for q, x in readlines(q):
        counter[q] += x

    iterator = range(n+1, 0, -1) if bigroot else range(1, n+1)
    for i in iterator:
        parent = edges[i]
        counter[i] += counter[parent]

    print(" ".join(map(str, counter[1:])))

main()
Problem p03030 (python)

Fixed submission:
n = int(input())


def f(n):
    n[1] = int(n[1])
    return n


a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

for c in ans:
    for d in c:
        print(d[2])

Buggy submission (verdict: Runtime Error):

a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

[print(c[2]) for c in ans[0]]
Problem p03050 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    def yakusu():
        for i in range(1, int(n**0.5)+1):
            if n%i == 0:
                yield i
                if i != n //i:
                    yield n//i

    for m in yakusu():
        m -= 1
        if m == 0:
            continue

        if n // m == n % m:
            yield m

print(sum(main()))

Buggy submission (verdict: Runtime Error):
n = int(input())
lst = range(2, n)

divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i-1)
        if i != n // i:
            divisors.append(n//i-1)

divisors.pop(0)
divisors.pop(1)
print(sum(divisors))

Buggy submission (verdict: Runtime Error):
n = int(input())
lst = range(2, n)

divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i-1)
        if i != n // i:
            divisors.append(n//i-1)

divisors.pop(0)
divisors.pop(1)
print(sum(divisors))
Problem p03061 (python)

Fixed submission:
from fractions import gcd
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))

    def pleaceAC():
        left = list(accumulate([0]+A, gcd))
        right = list(accumulate(reversed(A+[0]), gcd))
        for i in range(N):
            yield gcd(left[i], right[~(i+1)])

    print(max(pleaceAC()))


main()

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

def main():
    N = int(input())
    A = list(map(int, input().split()))

    def pleaceAC():
        yield reduce(gcd, A[1:])
        yield reduce(gcd, A[:-1])
        for i in range(1,N-1):
            a = reduce(gcd, A[:i])
            b = reduce(gcd, A[i+i:])
            yield gcd(a, b)

    print(max(pleaceAC()))


main()
Problem p03086 (python)

Fixed submission:
import sys
# input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        yield map(int, input().split())


def main():
    s = input()

    subst = 0
    for i in range(len(s)):
        if s[i] in "ACGT":
            subst += 1
        else:
            yield subst
            subst = 0
    
    yield subst
    

print(max(main()))

Buggy submission (verdict: Runtime Error):
import sys
# input = sys.stdin.readline
from itertools import accumulate

def readlines(n):
    for _ in range(n):
        yield map(int, input().split())


def main():
    s = input()

    subst = 0
    for i in range(len(s)):
        if s[i] in "ACGT":
            subst += 1
        else:
            yield subst
            subst = 0
        
    

print(max(main()))
Problem p03087 (python)

Fixed submission:
from itertools import accumulate

n, q = map(int, input().split())

s = input()

problems = [list(map(int, input().split())) for _ in range(q)]


def count(total, i):
    return total + 1 if s[i:i+2] == 'AC' else total


cumsum = list(accumulate([0] + list(range(n)), count))

for l, r in problems:
    print(cumsum[r-1] - cumsum[l-1])

Buggy submission (verdict: Runtime Error):
from itertools import accumulate

n, q = map(int, input().split())

s = input()

problems = [list(map(int, input().split())) for _ in range(q)]


def count(total, i):
    return total + 1 if s[i-1] + s[i] == 'AC' else total


cumsum = [0, *accumulate(range(1, n), count)]

for l, r in problems:
    print(cumsum[r-1] - cumsum[l-1])
Problem p03106 (python)

Fixed submission:
a, b, k = [int(s) for s in input().split()]


def f(s, l, k):
    numbers = []
    for i in range(1, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)

Buggy submission (verdict: Runtime Error):
a, b, k = [int(s) for s in input().split()]


def f(s, l, k):
    numbers = []
    for i in range(2, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)
Problem p03196 (python)

Fixed submission:
from collections import Counter
from functools import reduce

N,P = list(map(int,input().split()))
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

counter = Counter(prime_factorize(P))

ans = reduce(lambda total, x: total * x[0] ** (x[1]//N), counter.items(), 1)
print(ans)

Buggy submission (verdict: Runtime Error):
import qualified Data.Map.Strict as Map

primeFactorize :: Integer -> [Integer]
primeFactorize 1 = []
primeFactorize x =
    let v = head $ nativeFactors x in
        v : primeFactorize (x `div` v)
    where
        nativeFactors n = [a | a <- [2..n], n `mod` a == 0]

toCountMap :: (Ord k, Integral a) => [k] -> Map.Map k a
toCountMap xs = Map.fromListWith (+) $ zip xs (repeat 1)

main :: IO ()
main = do
    (n:p:_) <- fmap (map read . words) getLine :: IO[Integer]
    print $ solve n p

solve :: Integer -> Integer -> Integer
solve n p =
    let ps = Map.toList $ toCountMap $ primeFactorize p
    in foldr (\ (x, e) total -> total * (x ^ (e `div` n))) 1 ps
Problem p03231 (python)

Fixed submission:
from fractions import gcd

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

s = input()
t = input()

# accept
# a c p
# a  e

g = gcd(n, m)
a = n // g
b = m // g
for i in range(g):
    if s[i*a] != t[i*b]:
        print(-1)
        exit()

print(n*m//g)

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

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

s = input()
t = input()

# accept
# a c p
# a  e

# 最小公倍数。被ったらNG
l = n * m // gcd(n, m)
x = [None] * l
for i, c in enumerate(s):
    if i*l//n >= l:
        break
    x[i*l//n] = c

for i, c in enumerate(t):
    if i*l//m >= l:
        break
    
    a = x[i*l//m]
    if a is None:
        continue
    elif a != c:
        print(-1)
        exit()

print(l)

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

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

s = input()
t = input()

# accept
# a c p
# a  e

# 最小公倍数。被ったらNG
l = n * m // gcd(n, m)
x = [None] * (n*m)
for i, c in enumerate(s):
    x[i*l//n] = c

for i, c in enumerate(t):
    a = x[i*l//m]
    if a is None:
        continue
    elif a != c:
        print(-1)
        exit()

print(l)

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

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

s = input()
t = input()

# accept
# a c p
# a  e

# 最小公倍数。被ったらNG
l = n * m // gcd(n, m)
x = [None] * l
for i, c in enumerate(s):
    x[i*l//n] = c

for i, c in enumerate(t):
    a = x[i*l//m]
    if a is None:
        continue
    elif a != c:
        print(-1)
        exit()

print(l)
Problem p03241 (python)

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

def divisor(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if n % n//i == 0:
                res.append(n//i)

    res.sort()
    return res

d = divisor(M)
ans = 1
for x in d:
    m = M
    m -= x * (N - 1)
    if m > 0 and m % x == 0:
        ans = x

print(ans)

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

def divisor(n):
    if n == 1:
        return 1
    
    ans = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ans.append(i)
            if n % n//i == 0:
                ans.append(n//i)

    ans.sort()
    return ans

d = divisor(M)
ans = 1
for x in d:
    m = M
    m -= x * (N - 1)
    if m > 0 and m % x == 0:
        ans = x

print(ans)

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

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

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

prime = reversed(primes(m))

for p in prime:
    x = m - p
    if gcd(x, n-1) % p == 0:
        print(p)
        exit()
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())

notone = 1
notonei = 101
for i, n in enumerate(s):
    if n != "1":
        notone = int(n)
        notonei = i
        break

if k <= notonei:
    print(1)
else:
    print(notone)

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

notone = 101
for i, n in enumerate(s):
    if n != "1":
        notone = int(n)
        notonei = i
        break

if k < notonei:
    print(1)
else:
    print(notone)
Problem p03338 (python)

Fixed submission:
import sys
# input = sys.stdin.readline

def main():
    N = int(input())
    S = input()
    
    for i in range(N):
        left = set(S[:i])
        right = set(S[i:])

        yield len(left & right)


print(max(main()))

Buggy submission (verdict: Runtime Error):
import sys
# input = sys.stdin.readline

def main():
    N = int(input())
    S = input()
    
    for i in range(1, N-1):
        left = set(S[:i])
        right = set(S[i:])

        yield len(left & right)


print(max(main()))
Problem p03387 (python)

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

diff1 = c - b
a += diff1
diff2 = c - a
if diff2 % 2 == 0:
    diff2 //= 2
else:
    diff2 += 1
    diff2 //= 2
    diff2 += 1

print(diff1 + diff2)

Buggy submission (verdict: Runtime Error):
from itertools import product
a,b,c,d=list(input())
for o,p,q in product("-+",repeat=3):
    if eval(a+o+b+p+c+q+d)==7:
        print(a+o+b+p+c+q+d+"=7")
        break
Problem p03400 (python)

Fixed submission:
import sys
input = sys.stdin.readline

X = 0
D = 0

def loop():
    i=1
    a = int(input())
    while True:
        if i*a+1 <= D:
            yield 1
        else:
            break
        i += 1

def readlines():
    global X, D
    N = int(input())
    D, X = map(int, input().split())
    for _ in range(N):
        yield 1+sum(loop())

def main():
    return sum(readlines()) + X
	
if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

X = 0
D = 0

def loop():
    i=1
    a = int(input())
    while i*a+1 <= D:
      	yield 1
        i += 1

def readlines():
    global X, D
    N = int(input())
    D, X = map(int, input().split())
    for _ in range(N):
        yield 1+sum(loop())

def main():
    return sum(readlines()) + X
	
if __name__ == "__main__":
    print(main())
Problem p03436 (python)

Fixed submission:
import sys
#input = sys.stdin.readline
from collections import deque

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

initial = 0
grid = []
for _ in range(H):
    row = input()
    initial += row.count("#")
    grid.append(row)

def bfs():
    dire = [(1,0),(0,1),(-1,0),(0,-1)]
    q = deque()
    q.append((0, 0, 1))
    explored = set()
    explored.add((0, 0))
    while q:
        y, x, count = q.popleft()
        for h, w in dire:
            yh = y + h
            xw = x + w
            if yh < 0 or yh >= H or xw < 0 or xw >= W or grid[yh][xw] == "#" or (yh, xw) in explored:
                continue
            
            if (yh, xw) == (H-1, W-1):
                return count+1

            explored.add((yh, xw))
            q.append((yh, xw, count+1))

    return -1

path_count = bfs()

if path_count == -1:
    print(-1)
else:
    print(H*W - path_count - initial)

Buggy submission (verdict: Runtime Error):
import sys
#input = sys.stdin.readline
from collections import deque

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

initial = 0
grid = []
for _ in range(H):
    row = input()
    initial += row.count("#")
    grid.append(row)

def bfs():
    dire = [(1,0),(0,1),(-1,0),(0,-1)]
    q = deque()
    q.append((0, 0, 1))
    explored = set()
    explored.add((0, 0))
    while q:
        y, x, count = q.popleft()
        for h, w in dire:
            yh = y + h
            xw = x + w
            if yh < 0 or yh >= H or xw < 0 or xw >= W or grid[yh][xw] == "#" or (yh, xw) in explored:
                continue
            
            if (yh, xw) == (H-1, W-1):
                return count+1

            explored.add((yh, xw))
            q.append((yh, xw, count+1))

path_count = bfs()

print(H*W - path_count - initial)
Problem p03476 (python)

Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline
import bisect as bi
from operator import mul
from functools import reduce
import math
from itertools import accumulate

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def prime(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return is_prime

def main():
    q = int(input())
    is_prime = prime(10**5)

    def p(total, x):
        return total + (1 if is_prime[x] and is_prime[(x+1)//2] else 0)

    cumsum = list(accumulate(range(10**5), p))
    for l, r in readlines(q):
        print(cumsum[r] - cumsum[l-1])


main()

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input = sys.stdin.readline
import bisect as bi
from operator import mul
from functools import reduce
import math
from itertools import accumulate

def readlines(n):
    for _ in range(n):
        a, b = map(int, input().split())
        yield a, b

def prime(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return is_prime

def main():
    q = int(input())
    is_prime = prime(100)

    def p(total, x):
        return total + (1 if is_prime[x] and is_prime[(x+1)//2] else 0)

    cumsum = list(accumulate(range(100), p))
    for l, r in readlines(q):
        print(cumsum[r] - cumsum[l-1])


main()
Problem p02641 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n+1):
	for x in [-1,+1]:
		y = n + x*i
		if y not in a:
			print(y)
			exit(0)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n+1):
	for x in [1,-1]:
		y = n + x*i
		if y not in a:
			print(y)
			exit(1)
Problem p02817 (python)

Fixed submission:
a,b = map(str,input().split())
print(b+a)

Buggy submission (verdict: Runtime Error):
a,b = map(str,input().split())
print(b+c)
Problem p03316 (python)

Fixed submission:
S = int(input())
Slist = list(str(S))
res = 0
for i in Slist:
  res += int(i)
if S % res == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
Slist = list(S)
res = 0
for i in Slist:
  res += int(i)
print(int(S) % res = 0)
Problem p04032 (python)

Fixed submission:
str = input()
flg=0
for n in range(0,len(str)-2):
  if(str[n]==str[n+1]):
    print(n+1,n+2)
    flg =1
    break
  elif (str[n]==str[n+2]):
    print(n+1,n+3)
    flg=1
    break
if flg ==0:
  if str[len(str)-2]== str[len(str)-1]:
    print(len(str)-1,len(str))
  else:
    print(-1,-1)

Buggy submission (verdict: Runtime Error):
str = input()
flg=0
for n in range(0,len(str)-2):
  if(str[n]==str[n+1]):
    print(n+1,n+2)
    flg =1
    break
  elif (str[n]==str[n+2]):
    print(n+1,n+3)
    flg=1
    break
if flg =0:
  print(-1,-1)
Problem p02981 (python)

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

if( a*n < b ) :
    print(a*n)
else :
    print(b)

Buggy submission (verdict: Runtime Error):
def yo():
    l,r = map(int,input().split())

    a = l*r%2019
    for i in range(l,r) :
        for j in range(i+1,r+1):
            ij = i*j%2019
 
            if(ij==0) :
                return a

            if (a > ij) :
                a = ij


    return a



print(yo())
Problem p02999 (python)

Fixed submission:
x,a = map(int,input().split())
if ( x < a ) :
    print(0)
else :
    print(10)

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(int,input().split())

if(2*x == w and 2*y ==h) :
    ff = 1
else :
    ff = 0

print(str(w * h / 2) + " " + str(ff))

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(int,input().split())

hx = h * x
hx2 = h * (w-x)
wy = w * y
wy2 = w * (h-y)

if(hx > hx2) :
    d1 = hx2
else :
    d1 = hx

if(wy > wy2) :
    d2 = wy2
else :
    d2 = wy


if(d1 == d2) :
    ff = 0
else :
    ff = 0

if(d1 > d2) :
    print(str(d1) + " " + str(ff))
else :
    print(str(d2) + " " + str(ff))
Problem p03001 (python)

Fixed submission:
w,h,x,y = map(int,input().split())

if(2*x == w and 2*y ==h) :
    ff = 1
else :
    ff = 0

print(str(w * h / 2) + " " + str(ff))

Buggy submission (verdict: Runtime Error):
hx = h * x
hx2 = h * (w-x)
wy = w * y
wy2 = w * (h-y)

if(hx > hx2) :
    d1 = hx2
else :
    d1 = hx

if(wy > wy2) :
    d2 = wy2
else :
    d2 = wy


if(d1 == d2) :
    ff = 1
else :
    ff = 0

if(d1 > d2) :
    print(str(d1) + " " + str(ff))
else :
    print(str(d2) + " " + str(ff))
Problem p02646 (python)

Fixed submission:
a, v = map(int,input().split())
b, w = map(int,input().split())
t =int(input())

s = abs(b-a)
y = (v-w)

if y <= 0:
    print('NO')
else:
    m = s % y
    u = s //y
    if m == 0 and u <= t:
            print('YES')
    elif m != 0 and u + 1 <= t:
            print('YES')
    else:
        print('NO')

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

s = abs(b-a)
y = (v-w)

if y <= 0:
    print('NO')
else:
    m = s % y
    u = s //y
    if m == 0 and u <= t
            print('YES')
    else:
        print('NO')
Problem p02664 (python)

Fixed submission:
t = input()
m=len(t)
s = ''
for i in range(len(t)):
    if t[i] == 'P' or t[i] == 'D':
        s = s + t[i]
         
    if t[i] =='?':
        s = s+'D'
print(s)

Buggy submission (verdict: Runtime Error):
t = input()
m=len(t)
s = ''
if t[0] =='?':
    if t[1] =='D':
        s= s+'P'
    else:
        s= s+'D'
for i in range(1, m-1):
    if t[i] == 'P' or t[i] == 'D':
        s = s + t[i]
    elif t[i] == '?' and t[i-1] =='P' :
        s = s + 'D'
    elif t[i] == '?' and t[i +1] == 'D' :
        s = s + 'P'
    else:
        s = s + 'D'
if t[m-1] =='?':
    s = s +'D'
else:
    s = s + t[-1]

print(s)

Buggy submission (verdict: Runtime Error):
t = input()
s = ''
for i in range(len(t)):
    if t[i] == 'P' or t[i] == 'D':
        s = s + t[i]
    elif t[i] == '?' and t[i-1] =='P':
        s = s + 'D'
    elif t[i] == '?' and t[i +1] == 'D':
        s = s + 'P'
    else:
        s = s + 'D'
print(s)