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

Fixed submission:
N = int(input())

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

money = 1000
kabu = 0

for i in range(len(A)-1):
    if kabu != 0:
        if A[i] >= A[i + 1]:
            money += kabu * A[i]
            kabu = 0

    else:
        if A[i] < A[i + 1]:
            kabu = money // A[i]
            money -= kabu * A[i]

if kabu != 0:
    money += kabu * A[len(A) - 1]
    
print(money)

Buggy submission (verdict: Runtime Error):
N = int(input())

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

money = 1000

for i in range(N):
    t = money + (A[i + 1] - A[i]) * (money // A[i])
    money = max(money, t)

print(money)
Problem p02630 (python)

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

B = []
C = []

l = {}

for i in range(Q):
    b, c = list(map(int, input().split()))

    B.append(b)
    C.append(c)

res = 0
for i in A:
    if i in l:
        l[i] += 1
    else:
        l[i] = 1

    res += i

t = 0
for i in range(Q):
    if B[i] in l:
        t = l[B[i]]


        res += (C[i] - B[i]) * t

        l[B[i]] = 0
        if C[i] in l:
            l[C[i]] += t
        else:
            l[C[i]] = t

    print(res)

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

B = []
C = []

l = {}

for i in range(Q):
    b, c = list(map(int, input().split()))

    B.append(b)
    C.append(c)

res = 0
for i in A:
    if i in l:
        l[i] += 1
    else:
        l[i] = 1

    res += i

t = 0
for i in range(Q):
    t = l[B[i]]

    res += (C[i] - B[i]) * t

    l[B[i]] = 0
    l[C[i]] += t

    print(res)

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

B = []
C = []

l = []

for i in range(Q):
    b, c = list(map(int, input().split()))

    B.append(b)
    C.append(c)

t = 0

for i in A:
    if i > t:
        t = i

for i in range(t + 1):
    l.append(i)
    l[i] = 0

for i in A:
    l[i] = l[i] + 1

for i in range(Q):
    t = l[B[i]]
    l[B[i]] -= t
    l[C[i]] += t

    res = 0
    for num in range(len(l)):
        res += num * l[num]

    print(res)
Problem p02646 (python)

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

lange = abs(B - A)
s = V - W

res = 0

if s != 0:
    tmp = lange / s
    if tmp <= T and tmp >= 0:
        res = 1

if (res == 0):
    print("NO")
else:
    print("YES")

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

lange = abs(A - B)
s = V - W

res = 0

if s > 0:
    tmp = lange / s
    if tmp.float.is_integer() and tmp <= T:
        res = 1

if (res == 0):
    print("NO")
else:
    print("YES")

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

lange = abs(A - B)
s = V - W

res = 0

if (s > 0):
    if (lange / s >= T):
        res = 1


if (res == 0):
    print("NO")
else:
    print("YES")
Problem p03150 (python)

Fixed submission:
S = input()

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = i
        break

if t == -1:
    t = 7

for i in range(1, 8):
    if not S[-i] == key[-i]:
        t += i - 1
        break

if t >= 7:
    print("YES")
else:
    print("NO")

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

key = "keyence"

t = -1

for i in range(7):
    if not S[i] == key[i]:
        t = i
        break

ans = True

if t:
    for i in range(1, 7 - t + 1):
        if not S[-i] == key[-i]:
            ans = False
            break

if ans:
    print("YES")
else:
    print("NO")
Problem p03163 (python)

Fixed submission:
#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

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

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dp[i][j] = dp[i - 1][j]
        if i != 0 and x[i - 1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-x[i-1][0]] + x[i-1][1])

print(dp[-1][W])

Buggy submission (verdict: Runtime Error):
import sys
import numba as nb

input = sys.stdin.readline

@nb.njit
def main():
    N, W = map(int, input().split())
    x = [tuple(map(int, input().split())) for _ in range(N)]

    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for i, (w, v) in enumerate(x, 1):
        dpi = dp[i]
        dpim = dp[i-1]    
        for j in range(1, W + 1):
            if w <= j:
                a = dpim[j - w] + v
                if a > dpim[j]:
                    dpi[j] = a
                else:
                    dpi[j] = dpim[j]
            else:
                dpi[j] = dpim[j]

    print(dp[-1][W])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numba as nb

input = sys.stdin.readline

@nb.njit
N, W = map(int, input().split())
x = [tuple(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i, (w, v) in enumerate(x, 1):
    dpi = dp[i]
    dpim = dp[i-1]    
    for j in range(1, W + 1):
        if w <= j:
            a = dpim[j - w] + v
            if a > dpim[j]:
                dpi[j] = a
            else:
                dpi[j] = dpim[j]
        else:
            dpi[j] = dpim[j]

print(dp[-1][W])

Buggy submission (verdict: Runtime Error):
import sys
#import math
import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

x = [list(map(int, sys.stdin.readline())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dpi = dp[i]
        dpim = dp[i-1]
        if x[i - 1][0] <= j:
            dpi[j] = max(dpim[j], dpim[j - x[i - 1][0]] + x[i - 1][1])
        else:
            dpi[j] = dpim[j]

print(dp[-1][W])

Buggy submission (verdict: Runtime Error):
#import
#import math
import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

weight = [0] * N
value = [0] * N

for i in range(N):
    w, v = map(int, input().split())
    weight[i] = w
    value[i] = v



dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):

        if x[i - 1][0] <= j:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i - 1]] + value[i - 1])
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[-1][W])
Problem p03164 (python)

Fixed submission:
#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

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

dp = [[10**10] * (10 ** 5 + 10) for _ in range(N + 1)]

dp[0][0] = 0

#  i:N個目 j:価値

for i, (w, v) in enumerate(x, 1):
    for j in range(10**5 + 1):
        dp[i][j] = dp[i - 1][j]
        if j != 0 and v <= j:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - v] + w)

for i in range(10 ** 5, -1, -1):
    if dp[-1][i] <= W:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
#import
#import math
#import numpy as np
#= int(input())
#= input()
N, W = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]

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

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, W + 1):
        dp[i][j] = dp[i - 1][j]
        if i != 0 and x[i - 1][0] <= j:
            dp[i][j] = max(dp[i][j], dp[i-1][j-x[i-1][0]] + x[i-1][1])

print(dp[-1][W])
Problem p03168 (python)

Fixed submission:
#import
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
p = list(map(float, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

dp = [[0.0] * (N + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i, p in enumerate(p, 1):
    pp = 1 - p
    for j in range(i + 1):
        if j == 0:
            dp[i][j] = dp[i - 1][j] * pp
        elif j == i:
            dp[i][j] = dp[i - 1][j - 1] * p
        else:
            dp[i][j] = dp[i - 1][j - 1] * p + dp[i - 1][j] * pp

res = 0.0
n = N // 2 + 1

for cnt in dp[-1][n:]:
    res += cnt

print(res)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
p = list(map(float, readline().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

dp = [[0.0] * (N + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i, p in enumerate(p, 1):
    pp = 1 - p
    dpij = dp[i][j]
    dpi = dp[i - 1]
    for j in range(i + 1):
        if j == 0:
            dpij = dpi[j] * pp
        elif j == i:
            dpij = dpi[j - 1] * p
        else:
            dpij = dpi[j - 1] * p + dpi[j] * pp

res = 0.0
n = N // 2 + 1

for cnt in dp[-1][n:]:
    res += cnt

print(res)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
p = list(map(float, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

dp = [[0.0] * (N + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i, p in enumerate(p, 1):
    pp = 1 - p
    dpij = dp[i][j]
    dpi = dp[i - 1]
    for j in range(i + 1):
        if j == 0:
            dpij = dpi[j] * pp
        elif j == i:
            dpij = dpi[j - 1] * p
        else:
            dpij = dpi[j - 1] * p + dpi[j] * pp

    dp[i][j] = dpij
    
res = 0.0
n = N // 2 + 1

for cnt in dp[-1][n:]:
    res += cnt

print(res)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
p = list(map(float, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

dp = [[0.0] * (N + 1) for _ in range(N + 1)]

dp[0][0] = 1

for i, p in enumerate(p, 1):
    pp = 1 - p
    dpij = dp[i][j]
    dpi = dp[i - 1]
    for j in range(i + 1):
        if j == 0:
            dpij = dpi[j] * pp
        elif j == i:
            dpij = dpi[j - 1] * p
        else:
            dpij = dpi[j - 1] * p + dpi[j] * pp

res = 0.0
n = N // 2 + 1

for cnt in dp[-1][n:]:
    res += cnt

print(res)
Problem p03171 (python)

Fixed submission:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**9)
#import
#import math
#import numpy as np
N = int(input())
A = list(map(int, input().split()))

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


for w in range(1, N + 1):
    for l in range(N - w + 1):
        r = w + l
        dp[l][r] = A[l] - dp[l + 1][r]
        if r > 0:
            dp[l][r] = max(dp[l][r], A[r - 1] - dp[l][r - 1])

print(dp[0][N])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N = int(input())
A = list(map(int, input().split()))

dp = [[-1] * (N + 1) for _ in range(N + 1)]

# 半開区間A[r,l)における最大スコア
def calc(r, l):
    if dp[r][l] != -1:
        return dp[r][l]

    if l - r == 1:
        return A[r]

    elif l - r == 2:
        return max(A[r], A[r + 1]) - min(A[r], A[r + 1])

    res = max(A[r] - calc(r + 1, l), A[l - 1] - calc(r, l - 1))
    dp[r][l] = res
    return res

ans = calc(0, N)

print(ans)
Problem p03244 (python)

Fixed submission:
#!/usr/bin/env python3

#import
#import math
#import numpy as np
n = int(input())
V = list(map(int, input().split()))

even = {0:0}
odd = {0:0}

for i in range(n):
    v = V[i]
    if i % 2 == 0:
        if v in even:
            even[v] += 1
        else:
            even[v] = 1
    else:
        if v in odd:
            odd[v] += 1
        else:
            odd[v] = 1

omax = 0
emax = 0
onext = 0
enext = 0

for e in even:
    if even[e] > even[emax]:
        if even[emax] > even[enext]:
            enext = emax
        emax = e
    elif even[e] > even[enext]:
        enext = e

for o in odd:
    if odd[o] > odd[omax]:
        if odd[omax] > odd[onext]:
            onext = omax
        omax = o
    elif odd[o] > odd[onext]:
        onext = o

if omax != emax:
    print(n - even[emax] - odd[omax])
else:
    print(n - even[emax] - odd[omax] + min(even[emax] - even[enext], odd[omax] - odd[onext]))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

#import
#import math
#import numpy as np
n = int(input())
V = list(map(int, input().split()))

even = {}
odd = {}

for i in range(n):
    v = V[i]
    if i % 2 == 0:
        if v in even:
            even[v] += 1
        else:
            even[v] = 1
    else:
        if v in odd:
            odd[v] += 1
        else:
            odd[v] = 1

odic = {0:1}
edic = {0:1}

for o in odd:
    t = odd[o]
    if t in odic:
        odic[t].append(o)
    else:
        odic[t] = [o]

for e in even:
    t = even[e]
    if t in edic:
        edic[t].append(e)
    else:
        edic[t] = [e]

okey = list(odic.keys())
ekey = list(edic.keys())


maxo = okey[-1]
maxe = ekey[-1]

ans = n - maxo - maxe

if odic[maxo] == edic[maxe]:
    if len(odic[maxo]) == 1:
        nexto = okey[-2]
        nexte = ekey[-2]
        
    ans += maxe - max(nexto, nexte)

print(ans)
Problem p03497 (python)

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

dic = {}

for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

li = [0] * (N + 1)

#  li[i] = j  i:ボールの数 j:種類

for a in dic:
    li[dic[a]] += 1

ans = 0
k = len(dic)

for i in range(N):
    if li[i] > 0:
        if k - li[i] >= K:
            ans += i * li[i]
            k -= li[i]
        else:
            ans += i * (k - K)
            k -= li[i]

    if k <= K:
        break

print(ans)

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

dic = {}

for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

li = [0] * N

for a in dic:
    li[dic[a]] += 1

ans = 0
k = len(dic)

for i in range(N):
    if li[i] > 0:
        if k - li[i] >= K:
            ans += i * li[i]
            k -= li[i]
        else:
            ans += i * (k - li[i])
            k -= li[i]

    if k <= K:
        break

print(ans)
Problem p03633 (python)

Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]


def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)


if N == 1:
    print(T[0])
    exit()

res = T[0] * T[1] // gcd(T[0], T[1])

if N > 2:
    for i in range(2, N):
        r = res * T[i] // gcd(res, T[i])
        res = max(r, res)

print(res)

Buggy submission (verdict: Runtime Error):
#import
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}
T = [int(input()) for _ in range(N)]


def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)


if N == 1:
    print(T[0])

res = T[0] * T[1] // gcd(T[0], T[1])

if N > 2:
    for i in range(2, N):
        r = res * T[i] // gcd(res, T[i])
        res = max(r, res)

print(res)

Buggy submission (verdict: Runtime Error):
#import
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}
T = [int(input()) for _ in range(N)]


def gcd(x, y):
    if x < y:
        t = x
        x = y
        y = t

    if y == 0:
        return x

    else:
        return gcd(y, x % y)


res = T[0] * T[1] // gcd(T[0], T[1])

for i in range(2, N):
    r = res * T[i] // gcd(res, T[i])
    res = max(r, res)

print(res)
Problem p03945 (python)

Fixed submission:
#import
#import math
#import numpy as np
#= int(input())
S = input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

s = S[0]

r = 0

for i in range(1, len(S)):
    if s != S[i]:
        r += 1

    s = S[i]

print(r)

Buggy submission (verdict: Runtime Error):
#import
#import math
#import numpy as np
#= int(input())
S = input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

s = S[0]

r = 0

for i in range(1, len(S)):
    if s != S[i]:
        r += 1

    s = S[i]

print(res)
Problem p04013 (python)

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

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

maxint = 50 * N

dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]

dp[0][0][0] = 1

for xi, xe in enumerate(x, 1):
    for j in range(xi+1):
        for k in range(maxint + 1):
            dp[xi][j][k] = dp[xi - 1][j][k]
            
            if j >= 0 and k >= xe:
                dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
                

res = 0

for i in range(1, N+1):
    res += dp[N][i][i * A]

print(res)

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

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

maxint = 50 * max(x)

dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]

dp[0][0][0] = 1

for xi, xe in enumerate(x, 1):
    for j in range(xi+1):
        for k in range(maxint + 1):
            dp[xi][j][k] = dp[xi - 1][j][k]
            
            if j >= 0 and k >= xe:
                dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
                

res = 0

for i in range(1, N+1):
    res += dp[N][i][i * A]

print(res)
Problem p04014 (python)

Fixed submission:
import math

n = int(input())
s = int(input())


r = 0

if n == s:
    print(n + 1)
    exit()
elif n < s:
    print(-1)
    exit()

sq = int(math.sqrt(n))


# 2 <= d <= √n
for i in range(2, sq+1):
    nt = n
    st = 0

    while nt > 0:
        st += nt % i
        nt //= i

    if st == s:
        print(i)
        exit()
    
# √n < d <= n
for i in range(sq+1, 0, -1):
    b = (n - s) // i + 1
    
    st = n % b + n // b

    if n // b != b and st == s:
        print(b)
        exit()

print(-1)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = int(input())

r = 0

if n == s:
    print(n + 1)
    exit()

nn = int(math.sqrt(n)) + 1

for i in range(2, nn):
    nt = n
    st = 0

    while nt > 0:
        st += nt % i
        nt //= i

    if st == s:
        print(i)
        exit()
    
for i in range(nn, 0, -1):
    nt = n
    st = 0

    b = (n - s) // i + 1
    
    st = n % b + n // b

    if st == s:
        print(b)
        exit()

print(-1)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = int(input())

r = 0

if n == s:
    print(n + 1)
    exit()
elif n < s:
    print(-1)
    exit()

nn = int(math.sqrt(n)) + 1

for i in range(2, nn):
    nt = n
    st = 0

    while nt > 0:
        st += nt % i
        nt //= i

    if st == s:
        print(i)
        exit()
    
for i in range(nn, -1, -1):
    nt = n
    st = 0

    b = (n - s) // i + 1
    
    st = n % b + n // b

    if st == s:
        print(b)
        exit()

print(-1)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
s = int(input())

r = 0

if n == s:
    print(n + 1)
    exit()
elif n < s:
    print(-1)
    exit()
elif s == 1:
    print(n)
    exit()

nn = int(math.sqrt(n)) + 1    

for i in range(2, nn):
    nt = n
    st = 0

    while nt > 0:
        st += nt % i
        nt //= i

    if st == s:
        print(i)
        exit()
    
for i in range(2, nn):
    nt = n
    st = 0

    tt = (n - s) // (i + 1)
    
    while nt > 0:
        st += nt % tt
        nt //= tt

    if st == s:
        print(tt)
        exit()

print(-1)
Problem p02664 (python)

Fixed submission:
t = list(input())
n = len(t)
for i in range(n):
  if t[i] == '?':
    t[i] = 'D'
print(''.join(t))

Buggy submission (verdict: Runtime Error):
t = list(input())
n = len(t)
if n == 1:
  if t == '?':
    t = 'D'
elif n == 2:
  if t != 'PD' or t != 'DP':
    if t == '??':
      t = 'PD'
    else:
      for i in range(2):
        if t[i] == '?':
          t[i] = 'D'
  else:
    t = 'PD'
else:
  for i in range(n):
    if t[i] != '?':
      continue
    else:
      # if i == 0:
      #   if t[i+1] != 'P':
      #     t[i] = 'D'
      #     continue
      #   else:
      #     t[i] = 'P'
      #     continue
      # else:
      #   t[i] = 'D'
      t[i] = 'D'

if t = 'D'*n:
  t = 'P' + 'D'*n
print(''.join(t))

Buggy submission (verdict: Runtime Error):
t = list(input())
n = len(t)
if n == 1:
  if t == '?':
    t = 'D'
elif n == 2:
  if t == '??':
    t = 'PD'
  else:
    t.replace('?', 'D')
else:
  for i in range(n-1):
    if t[i] != '?':
      continue
    else:
      if i == 0:
        if t[i+1] != 'P':
          t[i] = 'D'
          continue
        else:
          t[i] = 'P'
          continue
      else:
        if t[i-1] == 'D' and t[i+1] != 'P':
          t[i] = 'P'
        else:
          t[i] = 'D'

if t[-1] =='?':
  t[-1] = 'D'

print(''.join(t))
Problem p02767 (python)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
ans = 10 ** 9
for p in range(0, 101):
    cnt = 0
    for i in x:
        cnt += (i-p)**2
    ans = min(ans, cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))
for p in range(1, n+1):
    cnt = 0
    for i in x:
        cnt += (i-p)**2
    ans = min(ans, cnt)
print(ans)
Problem p02772 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
for i in a:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
            continue
        else:
            print('DENIED')
            exit()
print('APPROVED')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 == 0 or a[i]%5 == 0:
            ans = 'APPROVED'
        else:
            ans = 'DENIED'
            break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in a:
    if i%2 == 0:
        if i%3 == 0 or i%5 == 0:
            ans = 'APPROVED'
        else:
            ans = 'DENIED'
            break
print(ans)
Problem p02802 (python)

Fixed submission:
# ABC 151C
n, m = map(int, input().split())
ac = 0
wa = 0
cnt = [0]*n
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if cnt[p] == -1:
        continue
    if s == 'AC':
        ac += 1
        wa += cnt[p]
        cnt[p] = -1
    else:
        cnt[p] += 1
print(ac, wa)

Buggy submission (verdict: Runtime Error):
# ABC 151C
n, m = map(int, input().split())
ps = list(input().split() for _ in range(m))
ac = 0
wa = 0
a = int(ps[0][0])
if m == 0:
    print(0, 0)
    exit()
for i in range(1, m):
    while int(ps[i][0]) <= int(ps[m-1][0]):
        if int(ps[i][0]) == a and ps[i][1] == 'WA':
            wa += 1
        elif int(ps[i][0]) == a and ps[i][1] == 'AC':
            ac += 1
            a += 1
        else:
            continue
print(ac, wa)
Problem p02921 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
cnt = 0
soc = 1
while soc < b:
    soc += a - 1
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
cnt = 0
soc = 1
while soc < b:
    soc += a - 1
    cnt += 1
print(cnt)