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

Fixed submission:
from collections import Counter

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

dic = Counter(A)

Q = int(input())

for _ in range(Q):
    b, c = map(int, input().split())
    if b in dic.keys():
        sumA += ((c-b)*dic[b])

        #変更後の数字は既にいる？
        if c in dic.keys():
            #個数を保持
            #bの個数をcに追加し、bを削除
            dic[c] += dic[b]
            del dic[b]
        else:
            dic[c] = dic[b]
            del dic[b]
        # print("C", C)
        
        
        
        # print(dic)
    # else:
    #     ans = sumA
    print(sumA)

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

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

dic = Counter(A)

Q = int(input())

for _ in range(Q):
    b, c = map(int, input().split())
    if b in dic.keys():
        ans = sumA+(dic[b]*(c-b))

        B = dic[b]
        if c in dic.keys():
            dic[c] += dic[b]
            del dic[b]
        else:
            dic[c] = dic[b]
            del dic[b]
        
        sumA += (dic[c]*c-B*b)
        
        # print(dic)
    print(ans)
Problem p02647 (python)

Fixed submission:
import numpy as np
from numba import njit

N, K = map(int, input().split())
A = np.array((list(map(int, input().split()))), dtype=np.int64)

@njit
def imos(A):
    B = np.zeros(N, dtype=np.int64)
    for i,x in enumerate(A):
        a = max(0, i-x)
        b = min(i+x, N-1)
        B[a] += 1
        if b+1 <= N-1:
            B[b+1] -= 1
    B = np.cumsum(B)
    return B

for i in range(K):
    if i >= 50:
        break
    A = imos(A)
print(*A)

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

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

def imos(A):
    B = np.zeros_like(A)
    for i, x in enumerate(A):
        a = max(0, i-x)
        b= min(i+x, N-1)
        B[a] += 1
        if b+1 <= N-1:
            B[b+1] -= 1
    B = np.cumsum(B)

for i in range(K):
    if i >= 50:
        break
    A = imos(A)
print(*A)
Problem p02684 (python)

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

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

ord = [-1 for _ in range(N)]
ord[0] = 0
v = A[0]-1
root = [0]

while ord[v] == -1:
    #ordに何回目のワープかが記録される
    ord[v] = len(root)
        #ワープの軌跡を記録
    root.append(v)

    #次の地点にワープ5
    v = A[v]-1

# print(ord)
# print(root)

#ord[v]:最終地点（ループ起点 or ループ前の道のり）
# ループ起点までの余分な手
l = ord[v]
#ループ距離
c = len(root) - l

if K < l:
    #ループ前にワープが終了した場合、最終地点を出力
    ans = root[K]
else:
    #ループする回数を計算
    # はじめにループ起点までの余分手をKから引く
    K -= l
    # ループのmodを計算
    K %= c
    # 余分手＋ループのmodの位置の国に止まる
    ans = root[l+K]
print(ans+1)

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

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

ord = [-1 for _ in range(N+1)]
v = 1
root = []

while ord[v] == -1:
    #ordに何回目のワープかが記録される
    ord[v] = len(root)
    #ワープの軌跡を記録
    root.append(v)
    #次の地点にワープ
    v = A[v-1]

# print("len(root)", len(root))
# print("ord[v]", ord[v])
# print("ord", ord)
# print("root", root)

#ord[v]:最終地点（ループ起点 or ループ前の道のり）
l = ord[v]
#ループ距離
c = len(root) - l

if K < l:
    #ループ前にワープが終了した場合、最終地点を出力
    ans = root[K]
else:
    #ループする回数を計算
    K -= l
    K %= c
    res = root[l+K]
print(res)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

ans = sorted(P[:X] + Q[:Y])

for i in range(min(C, X+Y)):
    if R[i] > ans[i]:
        ans[i] = R[i]

print(sum(ans))

Buggy submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

ans = sorted(P[:X] + Q[:Y])

for i in range(C):
    if R[i] > ans[i]:
        ans[i] = R[i]

print(sum(ans))
Problem p02743 (python)

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

if 4*a*b < (c-a-b)**2 and (c-a-b) > 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sympy

a, b, c = map(int, input().split())
if  sympy.sqrt(a)+sympy.sqrt(b) < sympy.sqrt(c):
    print("Yes")
else:
    print("No"


# a, b, c = map(int, input().split())

Buggy submission (verdict: Runtime Error):
import sympy

a, b, c = map(int, input().split())
if  sympy.sqrt(a)+sympy.sqrt(b) < sympy.sqrt(c):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sympy

a, b, c = map(int, input().split())
if  sympy.sqrt(a)+sympy.sqrt(b) < sympy.sqrt(c):
    print("Yes")
else:
    print("No")
Problem p02761 (python)

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

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

ans = [0 for _ in range(n)]
check = [False for _ in range(n)]

flag = 0

for i, j in a:
    if check[i-1] == 0 or ans[i-1] == j:
        ans[i-1] = j
        check[i-1] = True
    else:
        flag = 1
       
if check[0] == False and ans[0] == 0 and m != 0:
    ans[0] = 1
elif m == 0 and n != 1:
    ans[3-n] = 1

c = ""
for k in ans:
    c += str(k)

if flag == 1 or len(str(int(c))) != n:
    print(-1)
else:
    print(c)

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

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

ans = [0 for _ in range(n)]
check = [False for _ in range(n)]

flag = 0

for i, j in a:
    if check[i-1] == 0 or ans[i-1] == j:
        ans[i-1] = j
        check[i-1] = True
    else:
        flag = 1
       
if check[0] == False ans m != 0:
    ans[0] = 1

c = ""
for k in ans:
    c+=str(k)

if flag == 1 or len(str(int(c))) != n:
    print(-1)
else:
    print(c)
Problem p02843 (python)

Fixed submission:
X = int(input())
num = [105, 104, 103, 102, 101, 100]

dp = [0 for _ in range(X+1)]
dp[0] = 1
f = 1

for i in range(X+1):
    for j in num:
        if i-j >= 0:
            if dp[i-j]:
                dp[i] = 1

print(dp[X])

Buggy submission (verdict: Runtime Error):
X = int(input())
num = [105, 104, 103, 102, 101, 100]

dp = [0 for _ in range(X+1)]
dp[0] = 1
f = 1

for i in range(X+1):
    for j in num:
        if i-j >= 0:
            if dp[i-j]:
                dp[i] = 1

for i in num:
    if not dp[X-i]:
        f = 0

print(f)

Buggy submission (verdict: Runtime Error):
X = int(input())
'''
numの順番によっては買うことが出来ない金額が発生するためNG
num = [105, 104, 103, 102, 101, 100]

f = 0
for i in range(2**6):
    XX = X
    for j in range(6):
        if (i>>j)&1:
            XX %= num[j]
            if XX == 0:
                f = 1
print(f)
'''

num = [105, 104, 103, 102, 101, 100]

dp = [0 for _ in range(X)]
dp[0] = 1
f = 1

for i in range(X):
    for j in num:
        if i-j >= 0:
            if dp[i-j]:
                dp[i] = 1

for i in num:
    if not dp[X-i]:
        f = 0

print(f)

Buggy submission (verdict: Runtime Error):
X = int(input())
'''
numの順番によっては買うことが出来ない金額が発生するためNG
num = [105, 104, 103, 102, 101, 100]

f = 0
for i in range(2**6):
    XX = X
    for j in range(6):
        if (i>>j)&1:
            XX %= num[j]
            if XX == 0:
                f = 1
print(f)
'''

num = [105, 104, 103, 102, 101, 100]

dp = [0 for _ in range(X)]
dp[0] = 1
f = 1

for i in range(X):
    for j in num:
        if i-j >= 0
            if dp[i-j]:
                dp[i] = 1

for i in num:
    if not dp[X-i]:
        f = 0

print(f)

Buggy submission (verdict: Runtime Error):
X = int(input())
'''
numの順番によっては買うことが出来ない金額が発生するためNG
num = [105, 104, 103, 102, 101, 100]

f = 0
for i in range(2**6):
    XX = X
    for j in range(6):
        if (i>>j)&1:
            XX %= num[j]
            if XX == 0:
                f = 1
print(f)
'''

num = [105, 104, 103, 102, 101, 100]

dp = [0 for _ in range(X)]
dp[0] = 1
f = 1

for i in range(X):
    for j in num:
        if i-j >= 0 and dp[i-j]:
            dp[i] = 1

for i in num:
    if not dp[X-i]:
        f = 0

print(f)
Problem p02844 (python)

Fixed submission:

N = int(input())
S = input()

num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            num.append("{}{}{}".format(i, j, k))

ans = 0
for n in num:
    i = 0
    j = 0
    while j < N:
        # print(i, j)
        if n[i] == S[j]:
            i += 1
            j += 1
        else:
            j += 1
        if i == 3:
            ans += 1
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

N = int(input())
S = input()

num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            num.append(f"{i}{j}{k}")

ans = 0
for n in num:
    i = 0
    j = 0
    while j < N:
        # print(i, j)
        if n[i] == S[j]:
            i += 1
            j += 1
        else:
            j += 1
        if i == 3:
            ans += 1
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

N = int(input())
S = input()

num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            num.append(f"{i}{j}{k}")

ans = 0
for n in num:
    i = 0
    j = 0
    while j < N:
        # print(i, j)
        if n[i] == S[j]:
            i += 1
            j += 1
        else:
            j += 1
        if i == 3:
            ans += 1
            break
print(ans)

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

num = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            num.append(f"{i}{j}{k}")

ans = 0
for n in num:
    i = 0
    j = 0
    while j < N:
        # print(i, j)
        if n[i] == S[j]:
            i += 1
            j += 1
        else:
            j += 1
        if i == 3:
            ans += 1
            break
print(ans)
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
print(max(0, A-B*2))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max(0, A-B*2)
Problem p02900 (python)

Fixed submission:
from fractions import gcd

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

n = gcd(N, M)
# print(n)

if n == 1:
    print(1)
else:
    ans = 1

    
    for i in range(2, int(gcd(N, M)**0.5)+1):
        flag = 0
        # print("i", i)
        # print("n", n)
        if n%i == 0:
            while n%i == 0:
                n //= i
                # print(n)
            flag = 1
        # print("n", n)
        ans += flag

    print(ans if n == 1 else ans+1)

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

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

n = gcd(N, M)
# print(n)

if n == 1:
    print(1)
else:
    ans = 1

    
    for i in range(2, int(gcd(N, M)**0.5)+1):
        flag = 0
        # print("i", i)
        # print("n", n)
        if n%i == 0:
            while n%i == 0:
                n //= i
                # print(n)
            flag = 1
        # print("n", n)
        ans += flag

    print(ans if n == 1 else ans+1)

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

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

n = gcd(N, M)
# print(n)
ans = 1

for i in range(2, int(n**(1/2))+2):
    flag = 0
    # print("i", i)
    while True:
        if n%i == 0:
            n //= i
            # print(n)
            flag = 1
        else:
            break
    ans += flag

print(ans)
Problem p02918 (python)

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

#グループの個数
cnt = 1

for i in range(N-1):
    if S[i] != S[i+1]:
        cnt += 1

print(N - max(1, cnt - 2*K))

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

#グループの
cnt = 1

for i in range(N-1):
    if S[i] != S[i+1]:
        cnt += 1


print(N - max(1, cnt - 2*k))
Problem p02958 (python)

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

count = 0
for i in range(n):
    if i+1 != p[i]:
        p[i] == i+1
        count += 1

if count <= 2:
    print("YES")
else:
    print("NO")

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

dic = {}
for i in range(n-1):
    a = p[i+1]-p[i]
    if a in dic and a != 1:
        dic[a] += 1
    elif a not in dic and a != 1:
        dic[a] = 1

flag = False
for k,v in dic.values():
    if i == 2 :
        flag = True
        break
    else:
        continue

if flag:
    print("YES")
else:
    if len(dic) == 0:
        print("YES")
    else:
        print("NO")
Problem p02963 (python)

Fixed submission:
import math
s = int(input())
a = math.ceil(math.sqrt(s))
b = a**2-s
print(0,0,a,1,b,a)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return list(reversed(divisors))

s = int(input())
ll = make_divisors(s)
if s%2 == 0:
    print("0 0 0",ll[0],ll[1], "0")
else:
    print("0 1 1 0",ll[0],ll[1])
Problem p02975 (python)

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

t = 0
for a_i in a:
    t ^= a_i
    # print(t)
print("Yes" if t==0 else "No")

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

flag = 0
even = []
odd = []
for i in a:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i) 

if n%2 == 1:
    if len(odd) >= 1:
        flag = 1
    else:
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
                if aa in a:
                    count += 1
                if count < 2:
                    flag = 1
                    break
            else:
                continue
            break

else:
    if len(odd)/2 != len(even):
        flag = 1
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
            if aa in a:
                count += 1
            if count < 2:
                flag = 1
                break
        else:
            continue
        break

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

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

flag = 0
even = []
odd = []
for i in a:
    if i%2 == 0:
        even.append(i)
    else:
        odd.append(i) 

if n%2 == 1:
    if len(odd) >= 1:
        flag = 1
    else:
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
            if aa in a:
                count += 1
        if count < 2:
            flag = 1
            break

else:
    if len(odd)/2 != len(even):
        flag = 1
        for i in range(n):
            count = 0
            for j in range(i, n):
                aa = a[i]^a[j]
            if aa in a:
                count += 1
        if count < 2:
            flag = 1
            break

if flag == 1:
    print("No")
else:
    print("Yes")
Problem p02993 (python)

Fixed submission:
n = input()
flag = 0
for i in range(len(n)-1):
    if n[i] == n[i+1]:
        flag = 1

if flag == 1:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
n = int(input())
flag = 0
for i in range(len(n)-1):
    if n[i] == n[i+1]:
        flag = 1

if flag == 1:
    print("Bad")
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
n = int(input())
flag = 0
for i in range(len(n)-1):
  if n[i] == n[i+1]:
    flag = 1

if flag == 1:
  print("Bad")
else:
  print("Good)
Problem p02995 (python)

Fixed submission:
import fractions
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

a,b,c,d = map(int,input().split())
print((b-a+1)-b//c-b//d+b//lcm(c,d)+(a-1)//d+(a-1)//c-(a-1)//lcm(c,d))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x,y):
    return (x*y)//math.gcd(x,y)

a,b,c,d = map(int,input().split())
print((b-a+1)-b//c-b//d+b//lcm(c,d)+(a-1)//d+(a-1)//c-(a-1)//lcm(c,d))
Problem p02999 (python)

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

Buggy submission (verdict: Runtime Error):
x, a = int(input().split())
if x < a:
  print(0)
else:
  print(10)
Problem p03044 (python)

Fixed submission:
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
n=int(input())
edges=[[] for i in range(n)]
for i in range(n-1):
    a,s,w=map(int,input().split())
    edges[a-1].append([s-1,w]);edges[s-1].append([a-1,w])
colors=[-1]*n
colors[0]=1
def dfs(now):
    for to,cost in edges[now]:
        if colors[to]==-1:
            colors[to]=(cost+colors[now])%2
            dfs(to)

dfs(0)
print(*colors,sep="\n")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
#再帰回数の上限を変更
# sys.setrecursionlimit(10**9)

N = int(input())
# v = [list(map(int, input().split())) for _ in range(N-1)]

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(*color, sep="\n")

Buggy submission (verdict: Runtime Error):
N = int(input())
# v = [list(map(int, input().split())) for _ in range(N-1)]

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(*color, sep="\n")

Buggy submission (verdict: Runtime Error):
N = int(input())
# v = [list(map(int, input().split())) for _ in range(N-1)]

edge = [[] for _ in range(N)]

for i in range(N-1):
    v1, v2, w = map(int, input().split())
    edge[v1-1].append((v2-1, w))
    edge[v2-1].append((v1-1, w))

color = [-1 for _ in range(N)]
color[0] = 1

def dfs(x):
    for v, w in edge[x]:
        if color[v] == -1:
            color[v] = (w + color[x])%2
            dfs(v)



dfs(0)
print(color)
Problem p03061 (python)

Fixed submission:
from math import gcd

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

L = [0] * N
L[0] = A[0]

#配列の左から順番に最大公約数を求める
for i, a in enumerate(A):
    L[i] = gcd(L[max(0, i-1)], a)

# print("L", L)
R = [0] * N
R[0] = A[-1]

#配列の右から順番に最大公約数を求める
for i, a in enumerate(A[::-1]):
    R[i] = gcd(R[max(0, i-1)], a)

# print("R", R)
ans = 0

for i in range(N):
    #一番左の数字を削除
    if i == 0:
        ans = max(ans, R[N-2])
    #一番右の数字を削除
    elif i == N-1:
        ans = max(ans, L[N-2])
    #i+1番目の数字を削除
    else:
        ans = max(ans, gcd(L[i-1], R[N-i-2]))
    
print(ans)

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

def gcd(numbers):
    return reduce(math.gcdm numbers)

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

ans = []

if len(A) == 1:
    ans.append(A[0])
else:
    ans.append(gcd(A[1:]))
    ans.append(gcd(A[:N]))

    for i in range(1, N-1):
        l = []
        l.append(gcd(A[:i]))
        l.append(gcd(A[i+1:]))
        ans.append(gcd(l))

print(max(ans))

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

def gcd(numbers):
    return reduce(math.gcd, numbers)

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

ans = []
if len(a) != 1:
    ans.append(gcd(a[1:]))
    ans.append(gcd(a[:n]))

    for i in range(1, n-1):
        aaaa = []
        aaaa.append(gcd(a[:i]))
        aaaa.append(gcd(a[i+1:]))
        ans.append(gcd(aaaa))
else:
    ans.append(a[0])
    
print(max(ans))

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

def gcd(numbers):
    return reduce(math.gcd, numbers)

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

ans = []
ans.append(gcd(a[1:]))
ans.append(gcd(a[:n]))

for i in range(1, n-1):
    aaaa = []
    aaaa.append(gcd(a[:i]))
    aaaa.append(gcd(a[i+1:]))
    ans.append(gcd(aaaa))

print(max(ans))
Problem p03069 (python)

Fixed submission:
n = int(input())
s = input()
b = 0
w = s.count(".")
l = [w]
for i in range(1, n + 1):
    if s[i - 1] == "#":
        b += 1
    if s[i - 1] == ".":
        w -= 1
    l.append(b + w)
    # print(l)
print(min(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
b = 0
w = s.count(".")
l = [w]
for i in range(1, n + 1):
    if s[i - 1] == "#":
        b += 1
    if s[i - 1] == ".":
        w -= 1
    l.append(b + w)
    print(l)
print(min(l))
Problem p03076 (python)

Fixed submission:
A = [int(input()) for i in range(5)]
B = [a - a % 10 + 10 if a % 10 != 0 else a for a in A]
diff = [(b - a) for a, b in zip(A, B)]

print(sum(B)-max(diff))

Buggy submission (verdict: Runtime Error):
a = [int(input()) for i in range(5)]

a_one = [i % 10 for i in a if i % 10 != 0]
a_aaa = [i for i in a if i % 10 != 0]
a_aa = [i // 10 * 10 + 10 for i in a if i % 10 != 0]
a_two = [i for i in a if i % 10 == 0]
a_last = a_one.index(min(a_one))

ans = 0

for i in range(len(a_aa)):
    if i == a_last:
        continue
    else:
        ans += a_aa[i]

for i in a_two:
    ans += i

ans += a_aaa[a_last]
print(ans)
Problem p03086 (python)

Fixed submission:
s = input()
ans = []
acgt = ["A", "C", "G", "T"]

cnt = 0
for i in range(len(s)):
    if s[i] in acgt:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
ans.append(cnt)
print(max(ans))

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
acgt = ["A", "C", "G", "T"]

cnt = 0
for i in range(len(s)):
    if s[i] in acgt:
        cnt += 1
    else:
        ans.append(cnt)
        cnt = 0
print(max(ans))
Problem p03106 (python)

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

if A < B:
    n = A
else:
    n = B

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

print(l[-K])

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

if A < B:
    n = A
else:
    n = B

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

print(l[-K])

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

if A > B:
    n = A
else:
    n = B

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

print(l[-K])
Problem p03160 (python)

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

dp = [0]*n
for i in range(n):
    if i >= 2:
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]))
    elif i == 1:
        dp[i] = abs(a[i]-a[i-1])
print(dp[-1])

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

dp = [float("inf")]*10010
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
    # print(dp)
print(dp[N-1])

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

dp = [float("inf")]*10010
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
    # print(dp)
print(dp[N-1])