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

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

for i in range(5):
    if x[i] == 0:
        print(i+1)

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

import sympy

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

Ai = []
count = 0
for i in range(N):
    Ai = make_divisors(A[i])
    for j in range(len(Ai)):
        if Ai[j] in A and Ai[j] != A[i]:
            count += 1
            break

print(N - count)

Buggy submission (verdict: Runtime Error):
X, N = list(map(int, input().split()))
if N > 0:
    p = list(map(int, input().split()))
else:
    print(X)
    
y = list(range(1, 101))
for i in range(N):
    if p[i] in y:
        y.remove(p[i])
        
new_y = []
for i in range(len(y)):
    new_y.append(abs(y[i]-X))


print(y[new_y.index(min(new_y))])
Problem p03059 (python)

Fixed submission:
[print(int((t+0.5)//a)*b)for a,b,t in[[int(i)for i in input().split()]]]

Buggy submission (verdict: Runtime Error):
[print(a//t*b)for a,b,t in[[int(i)for i in input().split()]]
Problem p03323 (python)

Fixed submission:
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()\',")+'\n')

a,b = f()

print("Yay!") if abs(a-b) <= 1 else print(":(")

Buggy submission (verdict: Runtime Error):
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()\',")+'\n')

a = int(input())
b = int(input())

print("Yay!") if abs(a-b) <= 1 else print(":(")
Problem p03351 (python)

Fixed submission:
from sys import stderr
from functools import reduce
from operator import add
f = lambda: [int(i) for i in input().split()]
debug = lambda *x: stderr.write(reduce(add, repr(x)) + '\n')

a, b, c, d = f()
if (abs(a - b) <= d and abs(b - c) <= d) or abs(a - c) <= d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = int(input())
ans = 1
for i in range(2, 1000):
    j = 2
    while i**j <= x:
        ans = max(ans, i**j)
    j += 1
    if i > x:
        break
print(ans)
Problem p03425 (python)

Fixed submission:
N = int(input())
S = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    s = input()
    if s[0] in ["M","A","R","C","H"]:
        S[s[0]] += 1

print(S["M"] * S["A"] * (S["R"] + S["C"] + S["H"])
      + S["M"] * S["R"] * (S["C"] + S["H"])
      + S["M"] * S["C"] * S["H"]
      + S["A"] * S["R"] * (S["C"] + S["H"])
      + S["A"] * S["C"] * S["H"]
      + S["R"] * S["C"] * S["H"])

Buggy submission (verdict: Runtime Error):
N = int(input())
S = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    s = input()
    if s[0] in ["M","A","R","C","H"]
        S[s[0]] += 1

print(S["M"] * S["A"] * (S["R"]+S["C"]+S["H"]) + S["M"] * S["R"] * (S["C"] + S["H"]) + S["M"] * S["C"] * S["H"] + S["A"] * S["R"] * (S["C"] + S["H"]) + S["C"] * S["A"] * S["H"] +  S["R"] * S["C"] * S["H"])
Problem p03427 (python)

Fixed submission:
N = list(map(int,str(input())))
N_ = N[1:]
ans = N[0]+(9*len(N_))
if all([N_[i] == 9 for i in range(len(N_))]):
    print(ans)
else:
    print(ans-1)

Buggy submission (verdict: Runtime Error):
from math import log10
N = int(input())
ans = []
for i in range(1,int(log10(N))+1):
    ans.append((sum(map(int,list(str((int(N/(10**i))*(10**i)-1)))))))
print(max(ans))
Problem p03437 (python)

Fixed submission:
[print(x*(y-1)if x%y else-1)for x,y in[[int(i)for i in input().split()]]]

Buggy submission (verdict: Runtime Error):
[print(x*(y-1) if y%=x else -1) for x,y in [[int(i) for i in input().split()]]]

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

X,Y = [int(i) for i in input().split()]

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

i = 2
while True:
    if (X * i) % Y != 0:
        print(X*i)
        break
    elif (X * i) >= lcm(X,Y):
        print(-1)
        break
    else:
        i += 1
Problem p03545 (python)

Fixed submission:
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])
for i in [B,-1*B]:
    for j in [C,-1*C]:
        for k in [D,-1*D]:
            if A + i + j + k == 7:
                print("{:d}{:+d}{:+d}{:+d}=7".format(A,i,j,k),end="")
                exit()

Buggy submission (verdict: Runtime Error):
s = str
End = False
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])
for i in [B,-1*B]:
    for j in [C,-1*C]:
        for k in [D,-1*D]:
            if A + i + j + k == 7:
                print(f"{A:d}{i:+d}{j:+d}{k:+d}=7")
                exit()

Buggy submission (verdict: Runtime Error):
s = str
End = False
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])
for i in [B,-1*B]:
    for j in [C,-1*C]:
        for k in [D,-1*D]:
            if A + i + j + k == 7:
                print(f"{A:d}{i:+d}{j:+d}{k:+d}=7")
                End = True
                break
        if End:
            break
    if End:
        break
Problem p03563 (python)

Fixed submission:
r = int(input());g = int(input());print(2*g-r)

Buggy submission (verdict: Runtime Error):
r = int(input());g = int(input());print(2*G-r)
Problem p03624 (python)

Fixed submission:
letters = [chr(i) for i in range(97,123)]
string  = input()
for j in range(len(string)):
    if string[j] in letters:
        letters.remove(string[j])
    else:
        continue
if letters:
    print(letters[0])
else:
    print("None")

Buggy submission (verdict: Runtime Error):
letters = [chr(i) for i in range(97,123)]
string  = input()
for j in range(len(string)) if string[j] in letters:
    letters.remove(string[j])
print(letters[0])
Problem p03693 (python)

Fixed submission:
from sys import stderr, setrecursionlimit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def f(n=1):
    if n == 1:
        return [int(i) for i in input().split()]
    res = []
    for i in range(n):
        res.append([int(j) for j in input().split()])
    return res
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

rgb = int("".join(input().split()))
print("NO" if rgb%4 else "YES")

Buggy submission (verdict: Runtime Error):
print(["NO","YES"][int("".join(input().split()))])

Buggy submission (verdict: Runtime Error):
print(["NO","YES"][int(input())%4==0])
Problem p03699 (python)

Fixed submission:
from sys import stderr, setrecursionlimit, exit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def f(n=1, flag=False):
    res = []
    for _ in range(n):
        line = [int(i) for i in input().split()]
        if flag or len(line) == 1:
            res.append(line[0])
            flag = True
        else:
            res.append(line)
    if n == 1:
        return res[0]
    return res
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

n = f()
s = []
for i in range(n):
    s.append(int(input()))
s.sort(reverse=True)
su = sum(s)
# 10で割り切れるなら一番小さいやつを引く
# それでもだめなら2つ目，それもだめなら3つ目
# ↑1つ目≡0(mod 10),2つ目≡0(mod 10)なら当然1つ目+2つ目≡0(mod 10)なので3つ目のみ検討すればOK
if su % 10 != 0:
    print(su)
    exit()
i = -1
while True:
    su -= s[i]
    if su % 10 != 0:
        print(su)
        exit()
    su += s[i]
    i -= 1
    if i < -n:
        print(0)
        exit()

Buggy submission (verdict: Runtime Error):
from sys import stderr, setrecursionlimit, exit
from functools import reduce
from operator import add
setrecursionlimit(2147483647)
def f(n=1, flag=False):
    res = []
    for _ in range(n):
        line = [int(i) for i in input().split()]
        if flag or len(line) == 1:
            res.append(line[0])
            flag = True
        else:
            res.append(line)
    if n == 1:
        return res[0]
    return res
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(str(item))
        stderr.write(sep)
    stderr.write(end)

def solve(s, a, n):
    if s % 10 != 0:
        return s
    

n = f()
s = f(n)
s.sort(reverse=True)
su = sum(s)
# 10で割り切れるなら一番小さいやつを引く
# それでもだめなら2つ目，それもだめなら3つ目
# ↑1つ目≡0(mod 10),2つ目≡0(mod 10)なら当然1つ目+2つ目≡0(mod 10)なので3つ目のみ検討すればOK
if su % 10 != 0:
    print(su)
    exit()
i = -1
while True:
    su -= s[i]
    if su % 10 != 0:
        print(su)
        exit()
    su += s[i]
    i -= 1
    if i < -n:
        print(0)
        exit()
Problem p03738 (python)

Fixed submission:
a = int(input())
b = int(input())
if a < b:
    print("LESS")
elif a > b:
    print("GREATER")
else:
    print("EQUAL")

Buggy submission (verdict: Runtime Error):
a,b = [int(i) for i in input().split()]
if a < b:
    print("LESS")
elif a > b:
    print("GREATER")
else:
    print("EQUAL")
Problem p03945 (python)

Fixed submission:
from sys import stdin, stderr, setrecursionlimit, exit
setrecursionlimit(2147483647)
def debug(*args, **kwargs):
    print(*args, file=stderr, **kwargs)

ans = 0
s = input()

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

print(ans)

Buggy submission (verdict: Runtime Error):
[print(len(list(i.groupby(input())))-1)for i in[__import__('itertools')]][print(len(list(i.groupby(input())))-1)for i in[__import__('itertools')]]
Problem p04011 (python)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
    print(x*k + y*(n-k))
else:
    print(x*n)

Buggy submission (verdict: Runtime Error):
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add, repr(x)).strip("()\',") + '\n')

n, a = f()
x = f()
s = sum(x)

dp = [[[0 for i in range(n + 1)] for j in range(s + 1)] for k in range(n + 1)]
for i in range(n + 1):
    dp[i][0][0] = 1

for i in range(1, n + 1):
    for j in range(1, s + 1):
        for k in range(1, n + 1):
            dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - x[i - 1]][k - 1]

ans = 0
k = 1
while a * k <= s and k <= n:
    ans += dp[n][a*k][k]
    k += 1
print(ans)
Problem p02658 (python)

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

    if 0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > 1000000000000000000:
            print(-1)
            return

    print(ans)

main()

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

if 0 in A:
    print(0)
    return

ans = 1
for a in A:
    ans *= a
    if ans > 1000000000000000000:
        print(-1)
        return

print(ans)
Problem p02899 (python)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
tmp = np.argsort(A)+1
print(*tmp)

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

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

print(*np.argsort(A)+1)
Problem p03086 (python)

Fixed submission:
S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i, N):
        if all('ACGT'.count(c) == 1 for c in S[i:j+1]):
            ans = max(ans, j-i+1)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i, N):
        if all('ACGT'.count() == 1 for c in S[i:j+1]):
            ans = max(ans, j-i+1)
print(ans)
Problem p03160 (python)

Fixed submission:
import math

N = int(input())
vals = list(map(int, input().split()))


def chmin_orig(i1, i2):
    if dp[i1] > (dp[i2] + abs(vals[i1]-vals[i2])):
        dp[i1] = dp[i2] + abs(vals[i1]-vals[i2])
        return True
    return False


dp = [float('inf')] * 100010
dp[0] = 0
for i in range(N):
    chmin_orig(i, i-1)
    if i > 1:
        chmin_orig(i, i-2)

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]
 
 
dp = [[float('-inf') for _ in range(1000000)] for _ in range(N+10)]
dp[0][0] = 0
for i, (item_weight, item_value) in enumerate(items):  # i番目の品
    for total_weight in range(W+10):                   # 重さの合計
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        dp[i+1][total_weight+item_weight] = max(dp[i][total_weight]+item_value, dp[i+1][total_weight+item_weight])
        
print(dp[N][W])

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
vals = list(map(int, input().split()))


def chmin_orig(i1, i2):
    if dp[i1] > (dp[i2] + abs(vals[i1]-vals[i2])):
        dp[i1] = dp[i2] + abs(vals[i1]-vals[i2])
        return True
    return False


dp = [math.inf] * 100010
dp[0] = 0
for i in range(N):
    # chmin(dp[i], dp[i-1] + abs(vals[i]-vals[i-1]))
    chmin_orig(i, i-1)
    if i > 1:
        # chmin(dp[i], dp[i-2] + abs(vals[i]-vals[i-2]))
        chmin_orig(i, i-2)

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
def chmin_orig(i1, i2):
    if dp[i1] > (dp[i2] + abs(vals[i1]-vals[i2])):
        dp[i1] = dp[i2] + abs(vals[i1]-vals[i2])
        return True
    return False


dp = [math.inf] * 100010
dp[0] = 0
for i in range(N):
    chmin_orig(i, i-1)
    if i > 1:
        chmin_orig(i, i-2)

print(dp[N-1])
Problem p03161 (python)

Fixed submission:
N, K = map(int, input().split())
vals = list(map(int, input().split()))
costs = [0] * 100010
for i in range(len(vals)):
    costs[i] = vals[i]

dp = [float('inf')] * 100010
dp[0] = 0
for i in range(1, N):
    for j in range(1, K+1):
        if i-j >= 0:
            dp[i] = min(dp[i], dp[i-j] + abs(costs[i] - costs[i-j]))

# print(dp)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
vals = list(map(int, input().split()))
costs = [0] * 100010
for i in range(len(vals)):
    costs[i] = vals[i]


def chmin(i, j, dp, costs):
    if dp[i+j] > dp[i] + abs(costs[i] - costs[i+j]):
        dp[i+j] = dp[i] + abs(costs[i] - costs[i+j])
        return True
    return False


dp = [float('inf')] * 100010
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        chmin(i, j, dp, costs)

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
costs = list(map(int, input().split())) + [0] * 100010


def chmin(i, j, dp, costs):
    if dp[i+j] > dp[i] + abs(costs[i] - costs[i+j]):
        dp[i+j] = dp[i] + abs(costs[i] - costs[i+j])
        return True
    return False


dp = [float('inf')] * 100010
dp[0] = 0
for i in range(N-1):
    for j in range(1, K+1):
        chmin(i, j, dp, costs)

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
costs = list(map(int, input().split())) + [0] * 100010


def chmin(i, j, dp, costs):
    if dp[i+j] > dp[i] + abs(costs[i] - costs[i+j]):
        dp[i+j] = dp[i] + abs(costs[i] - costs[i+j])
        return True
    return False


dp = [float('inf')] * 100010
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        chmin(i, j, dp, costs)

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
costs = list(map(int, input().split())) + [0] * 100010


def chmin(i, j, dp, costs):
    if dp[i+j] > dp[i] + abs(costs[i] - costs[i+j]):
        dp[i+j] = dp[i] + abs(costs[i] - costs[i+j])
        return True
    return False


dp = [float('inf')] * 100010
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        chmin(i, j, dp, costs)

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
costs = list(map(int, input().split())) + [0] * 10010


def chmin(i, j, dp, costs):
    if dp[i+j] > dp[i] + abs(costs[i] - costs[i+j]):
        dp[i+j] = dp[i] + abs(costs[i] - costs[i+j])
        return True
    return False


dp = [float('inf')] * 100010
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        chmin(i, j, dp, costs)

print(dp[N-1])
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())
V = list(map(int, input().split()))

even = V[0::2]
odd = V[1::2]
even_max_cnt = Counter(even).most_common(2)
odd_max_cnt = Counter(odd).most_common(2)

if even_max_cnt[0][0] != odd_max_cnt[0][0]:
    ans = len(V) - even_max_cnt[0][1] - odd_max_cnt[0][1]
else:
    if len(even_max_cnt) == 1 or len(odd_max_cnt) == 1:
        ans = len(V) // 2
    else:
        ans = len(V) - max(even_max_cnt[0][1]+odd_max_cnt[1][1],
                           even_max_cnt[1][1]+odd_max_cnt[0][1])

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import math

n = int(input())
V = list(map(int, input().split()))

even = V[0::2]
odd = V[1::2]
even_max_cnt = Counter(even).most_common()
odd_max_cnt = Counter(odd).most_common()

cost = math.inf
res_freq_even = None
res_freq_odd = None
for e in even_max_cnt:
    for o in odd_max_cnt:
        if e[0] == o[0]:
            continue
        cost = min(cost, e[1]+o[1])
        res_freq_even = e
        res_freq_odd = o

if even_max_cnt[0][1] == len(even) and \
        odd_max_cnt[0][1] == len(odd) and \
        even_max_cnt[0][0] == odd_max_cnt[0][0]:
    ans = len(even)
else:
    ans = (len(even) - even_max_cnt[0][1]) + (len(odd) - odd_max_cnt[0][1])

print(ans)
Problem p03385 (python)

Fixed submission:
S = input()
if 'a' in S and 'b' in S and 'c' in S:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
s = set()
for i, n in enumerate(range(A, B+1)):
    if i+1 <= K:
        s.add(n)
for i, n in enumerate(reversed(range(A, B+1))):
    if i+1 <= K:
        s.add(n)
for i in sorted(s):
    print(i)
Problem p03494 (python)

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

tmp = min(A)
ans = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    ans += 1
print(ans)

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

tmp = min(A)
ans = 0
while all(a % 2 == 0 for a in A):
    A = all(a/2 for a in A)
    ans += 1
print(ans)
Problem p03633 (python)

Fixed submission:
from fractions import gcd


def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


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

ans = lcm(T)

print(ans)

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


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


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

ans = T[0]
for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

Buggy submission (verdict: Runtime Error):
import math


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


N = int(input())
T = [int(input()) for i in range(N)]

ans = T[0]
for t in T[1:]:
    ans = lcm(ans, t)

print(ans)

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


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


N = int(input())
T = [int(input()) for i in range(N)]

ans = T[0]
for t in T[1:]:
    ans = lcm(ans, t)

print(ans)
Problem p03854 (python)

Fixed submission:
# 確認

S = str(input())
words = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 100010

dp[0] = 1
for i in range(len(S)):
    if not dp[i]:
        continue
    for w in words:
        if S[i:i+len(w)] == w:
            dp[i+len(w)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
S = str(input())
str_list = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 10000

for i in range(len(S)):
    for s in str_list:
        if S[i:i+len(s)] == s:
            dp[i+len(s)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
str_list = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 10000

for i in range(len(S)):
    for s in str_list:
        if S[i:i+len(s)] == s:
            dp[i+len(s)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
str_list = ['dream', 'dreamer', 'erase', 'eraser']
dp = [0] * 100000

for i in range(len(S)):
    for s in str_list:
        if S[i:i+len(s)] == s:
            dp[i+len(s)] = 1

if dp[len(S)] == 1:
    print('YES')
else:
    print('NO')
Problem p02621 (python)

Fixed submission:
x=(int)(input())
y=x+(int)(pow(x,2))+(int)(pow(x,3))
print("{}".format(y))

Buggy submission (verdict: Runtime Error):
x=input()
print(x+(int)(pow(x,2)+(int)(pow(x,3)))
Problem p02621 (python)

Fixed submission:
def main():
    a = int(input())
    print(a + a*a + a*a*a)
    
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
a = input()
print(a + a*a + a*a*a)

Buggy submission (verdict: Runtime Error):
print(a + a*a + a*a*a)
Problem p02664 (python)

Fixed submission:
n = input()
ans=""
for i in range(len(n)):
    if n[i] == "D":
        ans = ans+"D"
    elif n[i] == "P":
        ans = ans+"P"
    elif n[i] == "?":
        ans = ans+"D"
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
ans=""
for i in range(len(n)):
    if n[i] == "D":
        ans = ans+"D"
    elif n[i] == "P":
        ans = ans+"P"
    elif n[i] == "?":
        if n[i-1]=="D" :
            if n[i+1]=="D"or"?":
                ans = ans+"P"
            else:
                ans = ans + "D"
        else:
            ans = ans + "D"
print(ans)
Problem p02675 (python)

Fixed submission:
n = input()
if n[-1] in "24579":
    print("hon")
if n[-1] in "0168":
    print("pon")
if n[-1] in "3":
    print("bon")

Buggy submission (verdict: Runtime Error):
n = input()
if n[-1] in "24579":
    print("hon")
elif n[-1] in "0168":
    print("pon")
else :
    pinnt("bon")
Problem p02677 (python)

Fixed submission:
a,b,h,m = map(int, input().split())
import math
a_x = a * math.cos(math.radians(30*h + 0.5*m))
a_y = a * math.sin(math.radians(30*h + 0.5*m))
b_x = b * math.cos(math.radians(6*m))
b_y = b * math.sin(math.radians(6*m))

ans = math.sqrt(abs(a_x - b_x)**2 + abs(a_y - b_y)**2)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

a,b,h,m = map(int, input().split())
start = 30*h
d = min(abs(start - 5.5 * m),360-abs(start - 5.5 * m))
if int(d)!=90 and int(d)!= 0:
    c = math.cos(math.radians(d))
    k = a**2+b**2-2*a*b*c
    ans = math.sqrt(k) 
    print(ans)
elif int(d) == 0:
    print(abs(a-b))
    print(c)
elif int(d) ==90:
    k= a**2+b**2
    ans = math.sqrt(k)
    print(ans)
Problem p03262 (python)

Fixed submission:
from fractions import gcd

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



ans = abs(z[0] - x)
for i in range(1, n):
    ans = gcd(ans, abs(x - z[i]))
print(ans)

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


ok = [1]
if m == 1:
    print(z[0]-n)
    exit()

for i in range(1,z[1]-z[0]):
    ans = True
    for j in range(len(z)-1):
        if abs(z[j]-m)%i != 0:
            ans = False
            break
    if ans :
        ok.append(i)
print(ok[-1])

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


ok = [1]
if m == 1:
    print(z[0]-n)
    exit()

for i in range(1,z[1]-z[0]):
    ans = True
    for j in range(len(z)):
        if abs(z[j]-m)%i != 0:
            ans = False
    if ans :
        ok.append(i)
print(ok[-1])
Problem p03457 (python)

Fixed submission:
n = int(input())
a,b,c=0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    sa = t-a
    if sa<abs(x-b)+abs(y-c):
        print("No")
        exit()
    else:
        tw = sa-abs(x-b)-abs(y-c)
        if tw%2!=0:
            print("No")
            exit()
    a,b,c=t,x,y
print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b,c=0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    sa = t-a
    if sa<abs(x-b)+abs(y-c):
        print("No")
        exit()
    else:
        tw = sa-abs(x-b)-abs(y-c)
        if tw%2!=0:
            print("No")
            exit()
    a,b,c=x,y,z
print("Yes")