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

Fixed submission:
N, X = map(int, input().split())
x = [abs(X - int(i)) for i in input().split()]

def f(a, b):
    if b == 0:
        return a
    return f(b, a % b)

tmp = 1
for i in range(len(x)-1):
    x[i+1] = f(x[i], x[i+1])

print(x[len(x)-1])

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = [abs(X - int(i)) for i in input().split()]

def f(a, b):
    if b == 0:
        return a
    return f(b, a % b)

tmp = 1
for i in range(len(x)-1):
    x[i+1] = f(x[i], x[i+1])

print(x[len(x)])
Problem p03274 (python)

Fixed submission:
N, K = map(int, input().split())
x = list(map(int, input().split()))
ret = 10 ** 9
for i in range(N-K+1):
    init = abs(x[i])
    dist = abs(x[i]-x[i+K-1])
    l = init + dist
    init = abs(x[i+K-1])
    r = init + dist
    ret = min(ret, l, r)
print(ret)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input())
x = list(map(int, input()))
ret = 10 ** 9
for i in range(N-k+1):
    init = abs(x[i])
    dist = abs(x[i]-x[i+k-1])
    l = init + dist
    init = abs(x[i+k-1])
    r = init + dist
    ret = min(l, r)
print(ret)
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
ret = "1"
for i in range(K):
    if len(S) < i-1:
        break
    if S[i] != "1":
        ret = S[i]
        break
print(ret)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
ret = "1"
for i in K:
    if len(S) <= K:
        break
    if S[i] != "1":
        ret = S[i]
        break
print(ret)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
ret = "1"
for i in K:
    if len(S) <= K:
        break
    if i != "1":
        ret = i
        break
print(ret)

Buggy submission (verdict: Runtime Error):
import re
S = input()
K = int(input())

next_t = S
now_t = ""

while next_t.ljust(K)[:K] != now_t.ljust(K)[:K]:
    now_t = next_t
    next_t = re.sub(r"[2]","22", next_t)
    next_t = re.sub(r"[3]","333", next_t)
    next_t = re.sub(r"[4]","4444", next_t)
    next_t = re.sub(r"[5]","55555", next_t)
    next_t = re.sub(r"[6]","666666", next_t)
    next_t = re.sub(r"[7]","7777777", next_t)
    next_t = re.sub(r"[8]","88888888", next_t)
    next_t = re.sub(r"[9]","999999999", next_t)

print(next_t[K])
Problem p03290 (python)

Fixed submission:
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(D)]

def dfs(question_num, rquired_point):
    if question_num < 0:
        return 10 ** 9

    point = (question_num+1) * 100
    ans_num = min(rquired_point // point, pc[question_num][0])
    score = ans_num * point

    if ans_num == pc[question_num][0]:
        score += pc[question_num][1]

    if rquired_point > score:
        ans_num += dfs(question_num-1, rquired_point-score)
    
    return min(ans_num, dfs(question_num-1, rquired_point))

print(dfs(D-1, G))

Buggy submission (verdict: Runtime Error):
def add(pc, p, G, tmp):
    for i in range(len(pc)-1, -1, -1):
        for k in range(pc[i][0]):
            p += (i+1) * 100
            tmp += 1
            if p >= G:
                return tmp


D, G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]
cnt = 10 ** 9
tmp = 0

for i in range(D):
    p = (i+1) * 100 * pc[i][0]
    p += pc[i][1]
    tmp = pc[i][0]
    if p < G:
        tmp += add(pc, p, G, tmp)
    cnt = min(cnt, tmp)
print(cnt)

Buggy submission (verdict: Runtime Error):
def add(pc, p, G, tmp):
    b = False
    for i in range(len(pc)-1, -1, -1):
        for k in range(pc[i][0]):
            p += (i+1) * 100
            tmp += 1
            if p >= G:
                return tmp


D, G = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(D)]
cnt = 0
tmp = 0

for i in range(D):
    p = (i+1) * 100 * pc[i][0]
    p += pc[i][1]
    tmp = pc[i][0]
    while p < G:
        tmp += add(pc, p, G, tmp)
    cnt = min(cnt, tmp)
print(cnt)
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
diff = max(abs(a-b), abs(b-c))
if diff <= d or abs(a-c) <= d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
if d*2 >= a-c
    print("Yes")
else:
    print("No")
Problem p03355 (python)

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

sub = []
for i in range(1, K+1):
    for k in range(len(s)-i+1):
        sub.append(s[k:k+i])

sub = list(set(sub))
sub.sort()
print(sub[K-1])

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

sub = []
for i in range(1, len(s)+1):
    for k in range(len(s)-i+1):
        sub.append(s[k:k+i])

sub = list(set(sub))
sub.sort()
print(sub[k+1])
Problem p03362 (python)

Fixed submission:
N = int(input())

def get_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
    for i, b in enumerate(is_prime):
        if b:
            yield i

primes_and_mod1 = []
for i in get_primes(55999):
    if i % 5 == 1:
        primes_and_mod1.append(i)

print(*primes_and_mod1[:N], sep=" ")

Buggy submission (verdict: Runtime Error):
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
    ret = []
    for i, p in enumerate(is_prime):
        if p:
            ret.append(i)
    return ret, is_prime
prime_list, is_prime = primes(55555 * 10)
prime_list.reverse()

from itertools import combinations

N = int(input())
A = []
for i in range(5):
    A.append(prime_list.pop())

while len(A) < N:
    n = prime_list.pop()
    if not any([is_prime[sum(comb)+n] for comb in combinations(A, 4)]):
        A.append(n)

print(*A, sep=" ")
Problem p03369 (python)

Fixed submission:
s = input()
n = s.count("o")
print(100 * n + 700)

Buggy submission (verdict: Runtime Error):
s = input()
n = s.count("o")
print(100 × n + 700)
Problem p03380 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
halfA = maxA // 2
tmp = 10 ** 9
r = 0
for a in A:
    if a == maxA:
        continue
    half = abs(halfA - a)
    if tmp > half:
        tmp = half
        r = a

print(maxA, r)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
tmp = 0
r = 0
for a in A:
    if maxA == a:
        continue
    combA = comb(maxA, a)
    if tmp < combA:
        tmp = combA
        r = a

print(maxA, r)
Problem p03407 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a+b => c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a+b =< c:
  print("Yes")
else:
  print("No")
Problem p03423 (python)

Fixed submission:
print(int(input())//3)

Buggy submission (verdict: Runtime Error):
print(input()//3)
Problem p03436 (python)

Fixed submission:
H, W = map(int, input().split())
C = [list(input()) for _ in range(H)]

# bfs 
C[0][0] = 0
pre_list = [(0,0)]
count = 0
 
while C[H-1][W-1] == '.' and len(pre_list) > 0:
    count += 1
    next_list = []
    for y,x in pre_list:
        for i,j in ((1,0),(0,-1),(0,1),(-1,0)):
            if y+i < 0 or x+j < 0 or y+i >= H or x+j >= W:
                continue
            if C[y+i][x+j] == '.':
                C[y+i][x+j] = count
                next_list.append((y+i,x+j))
    pre_list = next_list

if C[H-1][W-1] == '.':
    print(-1)
else:
    black = 0
    for h in C:
        for v in h:
            if v == "#":
                black += 1
    print(H*W-black-count-1)

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
# C = [list(input()) for _ in range(H)]
C = []
pre = 0
for i in range(H):
    c = list(input())
    pre += c.count("#")
    C.append(c)

list = [(0, 0)]
count = 1
 
while C[H-1][W-1] == '.':
    count += 1
    next_list = []
    for y,x in list:
        for i,j in ((1,0),(0,1),):
            if x+j < W and y+i < H:
                if C[y+i][x+j] == '.':
                    C[y+i][x+j] = count
                    next_list.append((y+i,x+j))
    list = list(set(next_list))
print(H*W-pre-count)
Problem p03487 (python)

Fixed submission:
N = input()

cnt = 0
strdit = {}
for i in input().split():
    i = int(i)
    if i not in strdit.keys():
        strdit[i] = 0
    strdit[i] += 1

for i in strdit.keys():
    if i > strdit[i]:
        cnt += strdit[i]
    else:
        cnt += strdit[i] - i

print(cnt)

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

cnt = 0
strdit = {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0}
for i in input().split():
    strdit[int(i)] += 1

for i in strdit.keys():
    if strdit[i] != 0:
        cnt += abs(i-strdit[i])

print(cnt)
Problem p03547 (python)

Fixed submission:
X, Y = input().split()

l ={ "A":1, "B":2, "C":3, "D":4, "E":5, "F":6 }
res = ""
if l[X] == l[Y]:
    res = "="
elif l[X] > l[Y]:
    res = ">"
else:
    res = "<"
print(res)

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())

l ={ "A":1, "B":2, "C":3, "D":4, "E":5, "F":6 }
res = ""
if l[X] == l[Y]:
    res = "="
elif l[X] > l[Y]:
    res = ">"
else:
    res = "<"
print(res)
Problem p03555 (python)

Fixed submission:
c1 = input()
c2 = input()
c1 = c1[2] + c1[1] + c1[0]
res = "YES" if c1 == c2 else "NO"
print(res)

Buggy submission (verdict: Runtime Error):
c1 = input()
c2 = input()
res = "YES" if c1[0] == c2[0] and c1[2] == c2[2] "NO"
print(res)
Problem p03569 (python)

Fixed submission:
S = input()
N = len(S)
L = list(S)
left_idx = 0
right_idx = N - 1
ret = 0
while left_idx < right_idx:
    l = S[left_idx]
    r = S[right_idx]
    if l == r:
        left_idx += 1
        right_idx -= 1
    elif l == "x":
        ret += 1
        left_idx += 1
    elif r == "x":
        ret += 1
        right_idx -= 1
    else:
        ret = -1
        break

print(ret)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
L = list(S)

# 回文の判定
def judge(s):
    n = len(s)
    half = n//2
    for i in range(half):
        if s[i] != s[n-1-i]:
            return False
    return True

removeX = S.replace("x", "")
n_removex = len(removeX)
if N % 2 == 0:
    center = removeX[n_removex//2-1:n_removex//2+1]
else:
    center = removeX[n_removex//2:n_removex//2+1]
left, right = S.split(center)
left_idx = 0
right_idx = len(right) - 1
ret = 0
while left_idx < len(left) and right_idx > -1:
    if left[left_idx] != right[right_idx]:
        if left[left_idx] == "x":
            right_idx -= 1
            ret += 1
        elif right[right_idx] == "x":
            left_idx += 1
            ret += 1
    else:
        left_idx += 1
        right_idx -= 1

ret += len(left) - left_idx
ret += right_idx + 1
if judge(removeX):
    print(ret)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
L = list(S)

# 回文の判定
def judge(s):
    n = len(s)
    half = n//2
    for i in range(half):
        if s[i] != s[n-1-i]:
            return False
    return True

removeX = S.replace("x", "")
n_removex = len(removeX)
if N % 2 == 0:
    center = removeX[n_removex//2-1:n_removex//2+1]
else:
    center = removeX[n_removex//2:n_removex//2+1]
left, right = S.split(center)
left_idx = 0
right_idx = len(right) - 1
ret = 0
while left_idx < len(left) and right_idx > -1:
    if left[left_idx] != right[right_idx]:
        if left[left_idx] == "x":
            right_idx -= 1
            ret += 1
        if right[right_idx] == "x":
            left_idx += 1
            ret += 1
    else:
        left_idx += 1
        right_idx -= 1

ret += len(left) - left_idx
ret += right_idx + 1
if judge(removeX):
    print(ret)
else:
    print(-1)
Problem p03583 (python)

Fixed submission:
def calc(N, h, n):
    base = 4 * h * n - N * n - N * h
    if base <= 0:
        return False, -1
    ret = (N*h*n) / base
    return ret == int(ret) and 0 <= ret <= 3500, int(ret)

N = int(input())

def f(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            judge, ret = calc(N,h,n)
            if judge:
                return h, n, ret
    return -1, -1, -1

print(*f(N))

Buggy submission (verdict: Runtime Error):
def calc(N, h, n):
    base = 4/N - 1/h - 1/n
    if base == 0:
        return False, 0
    ret = 1/base
    return ret == int(ret) and 0 <= ret <= 3500, int(ret)

N = int(input())

def f(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            judge, ret = calc(N,h,n)
            if judge:
                return h, n, ret

print(*f(N))

Buggy submission (verdict: Runtime Error):
def calc(N, h, n):
    base = 4/N - 1/h - 1/n
    if base == 0:
        return False, 0
    ret = 1/base
    return ret == int(ret) and ret >= 0, int(ret)

N = int(input())

def f(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            judge, ret = calc(N,h,n)
            if judge:
                return h, n, ret

print(*f(N))

Buggy submission (verdict: Runtime Error):
def calc(N, h, n):
    base = 4/N - 1/h - 1/n
    if base == 0:
        return False, 0
    ret = 1/base
    return ret == int(ret) and ret > 0, int(ret)

N = int(input())

def f(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            judge, ret = calc(N,h,n)
            if judge:
                return h, n, ret

print(*f(N))
Problem p03599 (python)

Fixed submission:
import math
A, B, C, D, E, F = map(int, input().split())

def calc(a, b):
    if a == 0 or b == 0: return 0
    return 100 * b / (a + b)
ans = (0, 0)
tmp = 0
ret = set()
for i in range(3001):
    for j in range(3001):
        water = i * A * 100 + j * B * 100
        if 1 > water or water > F: break
        for k in range((F-water)//C+1):
            for l in range((F-water)//D+1):
                suger = k * C + l * D
                if water + suger > F: break
                if water * E // 100 < suger: break
                t = calc(water, suger)
                #ret.add((t, water+suger, suger))
                if tmp <= t:
                    tmp = t
                    ans = (water+suger, suger)

#ret = list(ret)
#ret.sort(reverse=True)
print(*ans)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D, E, F = map(int, input().split())

def calc(a, b):
    if a == 0 or b == 0: return 0
    return 100 * b / (a + b)
ans = 0
tmp = 0
for i in range(F//100+1):
    for j in range(F//100+1):
        water = i * 100 + j * 100
        if 1 > water or water > F: break
        for k in range(F//C+1):
            for l in range(F//D+1):
                suger = k * C + l * D
                if water + suger > F: break
                if water * E // 100 < suger: break
                t = calc(water, suger)
                if tmp < t:
                    tmp = t
                    ans = (water+suger, suger)

print(*ans)
Problem p03651 (python)

Fixed submission:
def gcd(x, y):
    '''
    最大公約数の計算
    '''
    if y == 0:
        return x
    return gcd(y, x % y)
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

# いずれか2つの数字のGCDが1 必ずTrue
# いずれか2つの数字のGCDが2 かつ Ai - K % 2 == 0 のものが存在する場合 True
# いずれか2つのGCDが計算できれば、答えが導けるが、いずれか2つの組み合わせはA * (A-1) // 2通りあるから間に合わない
# 累積GCDで1になる → どうにかこうにか1にできる
# 累積GCDで2になる → どの組み合わせをとっても2にしかならない


def main():
    ma = max(A)
    if ma < K:
        return False
    if K in A:
        return True
    g = A[0]
    for a in A:
        g = gcd(g, a)
    for a in A:
        if (a-K) % g == 0:
            return True
    return False


if main():
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

# いずれか2つの数字のGCDが1 必ずTrue
# いずれか2つの数字のGCDが2 かつ Ai - K % 2 == 0 のものが存在する場合 True
# いずれか2つのGCDが計算できれば、答えが導けるが、いずれか2つの組み合わせはA * (A-1) // 2通りあるから間に合わない
# 累積GCDで1になる → どうにかこうにか1にできる
# 累積GCDで2になる → どの組み合わせをとっても2にしかならない


def main():
    ma = max(A)
    if ma < K:
        return False
    if K in A:
        return True
    gcd = A[0]
    for a in A:
        gcd = math.gcd(gcd, a)
    for a in A:
        if (a-K) % gcd == 0:
            return True
    return False
    

if main():
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03659 (python)

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

l = [0] * (N+1)
r = [0] * (N+1)

for i in range(N):
    l[i+1] = l[i] + a[i]

for i in range(N-1,-1,-1):
    r[i] = r[i+1] + a[i]

res = []

for i in range(1,len(l)-1):
    res.append(abs(l[i]-r[i]))

print(min(res))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]
res = []
for i in range(1,len(a)):
    res.append(abs(a[:i+1]-a[i:]))

print(min(res))
Problem p03732 (python)

Fixed submission:
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

minw = min(w)
for i in range(N):
    w[i] -= minw

ww = [[] for _ in range(4)]
for i, o in enumerate(w):
    ww[o].append(v[i])
for i in range(4):
    ww[i].sort(reverse=True)

ans = 0
for i in range(len(ww[0])+1):
    isum = sum(ww[0][:i])
    for j in range(len(ww[1])+1):
        jsum = sum(ww[1][:j])
        for k in range(len(ww[2])+1):
            ksum = sum(ww[2][:k])
            for t in range(len(ww[3])+1):
                tsum = sum(ww[3][:t])
                weight = minw * i + (minw+1) * j + (minw+2) * k + (minw+3) * t
                if weight <= W:
                    ans = max(ans, isum+jsum+ksum+tsum)
print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0] * 10010 for _ in range(N+1)]
minw = min(w)
for i in range(N):
    w[i] -= minw
    w[i] += 1
for i in range(N):
    for j in range(10000):
        dp[i+1][j] = dp[i][j]
        if j-w[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])

print(dp[N][min(W-minw,10000)])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    w[i] = x
    v[i] = y

dp = [[0] * 10010 for _ in range(N+1)]
minw = min(w)
for i in range(N):
    w[i] -= minw
    w[i] += 1
for i in range(N):
    for j in range(10000):
        dp[i+1][j] = dp[i][j]
        if j-w[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])
    
print(dp[N][W-minw])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    w[i] = x
    v[i] = y

dp = [[0] * 1010 for _ in range(N+1)]
minw = min(w)
for i in range(N):
    w[i] -= minw
    w[i] += 1
for i in range(N):
    for j in range(10000):
        dp[i+1][j] = dp[i][j]
        if j-w[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])
    
print(dp[N][W-minw])

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    w[i] = x
    v[i] = y

dp = [[0] * 1010 for _ in range(N+1)]
minw = min(w)
for i in range(N):
    w[i] -= minw
    w[i] += 1
for i in range(N):
    for j in range(1000):
        dp[i+1][j] = dp[i][j]
        if j-w[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])
    
print(dp[N][W-minw])
Problem p03830 (python)

Fixed submission:
N=int(input())
mod=10**9+7

def prime_factorization(n):
    '''
    素因数分解を求める

    Parameters:
    n : int
        求める数
    
    Returns:
    r : list
        素因数分解の結果
    '''
    r=[1]*(n+1)
    for i in range(1,n+1):
        for j in range(2,i+1):
            while i % j == 0:
                r[j] += 1
                i //= j
    
    return r

r = prime_factorization(N)
ans = 1
for i in r:
    ans *= i
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
mod=10**9+7

def prime_factorization(n):
    '''
    素因数分解を求める

    Parameters:
    n : int
        求める数
    
    Returns:
    r : list
        素因数分解の結果
    '''
    r=[1]*(n+1)
    for i in range(1,n+1):
        for j in range(2,i+1):
            while i % j == 0:
                r[j] += 1
                i //= j
    
    return r

r = prime_factorization(N)
ans = 1
for i in r:
    ans *= i
    ans %= mod

print(ans)
Problem p03994 (python)

Fixed submission:
S = list(input())
L = len(S)
K = int(input())
idx = 0
while K > 0:
    # aまでの必要な回数
    if S[idx] == "a" and idx < L-1:
        idx += 1
        continue
        
    k = 123 - ord(S[idx])
    if k > K:
        if idx < L-1:
            # aまで操作できないのに、操作すると辞書順でより後ろの文字列になってしまうので、次の文字へ
            idx += 1
        else:
            # 一番後ろの場合
            t = chr(ord(S[idx])+(K%26))
            S[idx] = t
            K = 0
    else:
        K -= k
        S[idx] = "a"
        if idx < L-1:
            idx += 1

print("".join(S))

Buggy submission (verdict: Runtime Error):
S = list(input())
L = len(S)
K = int(input())
idx = 0
while K > 0:
    # aまでの必要な回数
    if S[idx] == "a" and idx < L-1:
        idx += 1
        continue
    k = 123 - ord(S[idx])
    if k > K:
        if idx < L-1:
            # aまで操作できないのに、操作すると辞書順でより後ろの文字列になってしまうので、次の文字へ
            idx += 1
        else:
            # 一番後ろの場合
            t = chr(ord(S[idx])+(K%26))
            S[idx] = t
            K = 0
    else:
        K -= k
        S[idx] = "a"
        idx += 1

print("".join(S))

Buggy submission (verdict: Runtime Error):
S = list(input())
L = len(S)
K = int(input())
idx = 0
while K > 0:
    # aまでの必要な回数
    k = 123 - ord(S[idx])
    if k > K:
        if idx < L-1:
            idx += 1
        else:
            t = chr(ord(S[idx])+(K%26))
            S[idx] = t
            K = 0
    else:
        K -= k
        S[idx] = "a"
        idx += 1

print("".join(S))
Problem p03150 (python)

Fixed submission:
a = input()
key = "keyence"
for i in range(len(a)):
  for j in range(i, len(a)):
    if (a[:i] + a[j:] == key):
      print("YES")
      exit(0)
print("NO")

Buggy submission (verdict: Runtime Error):
in = input()
key = "keyence"
for i in range(len(in)):
  for j in range(i, len(in)):
    if (in[i:j] == key):
      print("YES")
      exit()
print("NO")

Buggy submission (verdict: Runtime Error):
in = input()
key = "keyence"
for i in range(len(in)):
  for j in range(i, len(in)):
    if (in[i:j] == key):
      print("YES")
      exit
print("NO")
Problem p03294 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(sum(a)-len(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
print(sum(a)-len(a))
Problem p03309 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i+1
b = sorted(a)
center1 = b[n//2]
center2 = 0
if not n == 1:
    center2 = b[n//2+1]
buf1 = 0
buf2 = 0
for i in range(n):
    buf1 += abs(b[i]-center1)
    buf2 += abs(b[i]-center2)
print(int(min(buf1, buf2)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i+1
b = sorted(a)
center1 = b[n//2+1]
center2 = 0
if not n == 1:
    center2 = b[n//2]
buf1 = 0
buf2 = 0
for i in range(n):
    buf1 += abs(b[i]-center1)
    buf2 += abs(b[i]-center2)
print(int(min(buf1, buf2)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i+1
b = sorted(a)
center1 = b[n//2+1]
center2 = b[n//2]
buf1 = 0
buf2 = 0
for i in range(n):
    buf1 += abs(b[i]-center1)
    buf2 += abs(b[i]-center2)
print(int(min(buf1, buf2)))
Problem p03543 (python)

Fixed submission:
a = input();
if ((a[0] == a[1]) & (a[1] == a[2])) : print('Yes')
elif ((a[1] == a[2]) & (a[2] == a[3])) : print('Yes')
else : print('No')

Buggy submission (verdict: Runtime Error):
a = input();
if (a[0] == a[1] & a[1] == a[2]) print('Yes')
elif (a[1] == a[2] & a[2] == a[3]) print('Yes')
else print('No')