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

Fixed submission:
n,K = map(int,input().split())
use = [0,1,2,3,4,5,6,7,8,9]
useless = list(map(int,input().split()))
for i in range(K):
  use.remove(useless[i])
k = 10 - K
time = [0]
def suc(time):
  now = 0
  while True:
    if now >= len(time):
      time.append(0)
      break
    elif time[now] != k-1:
      time[now] += 1
      break
    else:
      time[now] = 0
      now += 1
  return time
#print(suc([0]))
#print(suc([1,1,1,1]))
#print(suc([1,0,1,1]))
while True:
  pay = 0
  for j in range(len(time)):
    pay += use[time[j]] * 10 ** j
  if pay >= n:
    print(pay)
    break
  time = suc(time)

Buggy submission (verdict: Runtime Error):
n,K = map(int,input().split())
use = [0,1,2,3,4,5,6,7,8,9]
useless = list(map(int,input().split()))
for i in range(K):
  use.remove(useless[i])
k = 10 - K
time = [0]
def suc(time):
  now = 0
  while True:
    if now >= len(time):
      time.append(1)
      break
    elif time[now] != k-1:
      time[now] += 1
      break
    else:
      time[now] = 0
      now += 1
  return time
#print(suc([0]))
#print(suc([1,1,1,1]))
#print(suc([1,0,1,1]))
while True:
  pay = 0
  for j in range(len(time)):
    pay += use[time[j]] * 10 ** j
  if pay >= n:
    print(pay)
    break
  time = suc(time)

Buggy submission (verdict: Runtime Error):
n,K = map(int,input().split())
use = [0,1,2,3,4,5,6,7,8,9]
useless = list(map(int,input().split()))
for i in range(K):
  use.remove(useless[i])
k = 10 - K
time = [0]
def suc(time):
  now = 0
  while True:
    if now >= len(time):
      time.append(1)
      break
    elif time[now] != k-1:
      time[now] += 1
      break
    else:
      time[now] = 0
      now += 1
  return time
#print(suc([0]))
#print(suc([1,1,1,1]))
#print(suc([1,0,1,1]))
while True:
  pay = 0
  for j in range(len(time)):
    pay += use[time[j]] * 10 ** j
  if pay >= n:
    print(pay)
    break
  time = suc(time)
Problem p02536 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

for _ in range(M):
    a,b = map(int, input().split())
    uni.union(a-1,b-1)

print(uni.group_count()-1)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

for _ in range(M):
    a,b = map(int, input().split())
    uni.union(a,b)

print(uni.group_count()-1)
Problem p02760 (python)

Fixed submission:
import numpy as np

bingo = np.zeros((3,3))
bin_bingo = np.zeros((3,3))

for i in range(3):
    bingo[i] = list(map(int, input().split()))



N = int(input())

for _ in range(N):
    num = int(input())
    bin_bingo = np.logical_or(bin_bingo, bingo == num)

# find bingo
lin1 = np.array([[True, True, True], [False, False, False], [False, False, False]])
lin2 = np.array([[False, False, False],[True, True, True], [False, False, False]])
lin3 = np.array([[False, False, False], [False, False, False], [True, True, True]])
col1 = lin1.T
col2 = lin2.T
col3 = lin3.T

sla1 = np.array([[True, False, False], [False, True, False], [False, False, True]])
sla2 = np.array([[False, False, True], [False, True, False], [True, False, False]])

def is_bingo(src, tmp):
    return (np.logical_and(src, tmp) == tmp).all()

flg = False
if is_bingo(bin_bingo, lin1):
    flg = True
elif is_bingo(bin_bingo, lin2):
    flg = True
elif is_bingo(bin_bingo, lin3):
    flg = True
elif is_bingo(bin_bingo, col1):
    flg = True
elif is_bingo(bin_bingo, col2):
    flg = True
elif is_bingo(bin_bingo, col3):
    flg = True
elif is_bingo(bin_bingo, sla1):
    flg = True
elif is_bingo(bin_bingo, sla2):
    flg = True

if flg:
    print('Yes')
else:
    print('No')

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

bingo = np.zeros((3,3))
bin_bingo = np.zeros((3,3))


for i in range(3):
    bingo[i] = list(map(int, input().split()))

N = int(input())

for _ in range(N):
    num = int(input())
    bin_bingo = np.logical_or(bin_bingo, bingo == num)

# find bingo
lin1 = np.array([[True, True, True], [False, False, False], [False, False, False]])
lin2 = np.array([[False, False, False],[True, True, True], [False, False, False]])
lin3 = np.array([[False, False, False], [False, False, False], [True, True, True]])
col1 = lin1.T
col2 = lin2.T
col3 = lin3.T

sla1 = np.array([[True, False, False], [False, True, False], [False, False, True]])
sla2 = np.array([[False, False, True], [False, True, False], [True, False, False]])

def is_bingo(src, tmp):
    return (np.logical_and(bin_bingo, sla1) == sla1).all()

flg = False
if is_bingo(bin_bingo, lin1):
    flg = True
elif is_bingo(bin_bingo, lin2):
    flg = True
    
elif is_bingo(bin_bingo, lin3):
    flg = True

elif is_bingo(bin_bingo, col1):
    flg = True
elif is_bingo(bin_bingo, col2):
    flg = True
elif is_bingo(bin_bingo, col3):
    flg = True
elif is_bingo(bin_bingo, sla1):
    flg = True
elif is_bingo(bin_bingo, sla2):
    flg = True

if flg:
    print('Yes')
else:
    print('No')
Problem p02768 (python)

Fixed submission:
n,a,b = map(int, input().split())
MOD = 10**9 + 7
allpair = pow(2,n,MOD)

def combo(n,k):
    c = 1
    for i in range(k):
        c *= n - i
        c %= MOD

    d = 1
    for i in range(1, k+1):
        d *= i
        d %= MOD

    return (c * pow(d, MOD-2, MOD)) % MOD

print((allpair - combo(n, a) - combo(n, b) - 1) % MOD)

Buggy submission (verdict: Runtime Error):

n,a,b = map(int, input().split())
MOD = 10**9 + 7
allpair = pow(2,n,MOD)

def combo(n,k):
    c = 1
    for i in range(k):
        c *= n - i
        c %= MOD

    d = 1
    for i in range(1, k+1):
        d *= i
        d %= MOD

    return (c * pow(d, mod-2, MOD)) % MOD

print((allpair - combo(n, a) - combo(n, b) - 1) % MOD)

Buggy submission (verdict: Runtime Error):

n,a,b = map(int, input().split())
MOD = 10**9 + 7
allpair = pow(2,n,MOD)

N = n
# 早いnCrの準備ここから
fact = [0] * (N+1)
fact_inv = [0] * (N+1)
inv = [0] * (N+1)

fact[0] = fact[1]  = 1
fact_inv[0] = fact_inv[1] = 1
inv[1] = 1

for i in range(2, N+1):
    fact[i] = fact[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD # //で良いのかな?
    fact_inv[i] = fact_inv[i-1] * inv[i] % MOD

def combo(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * (fact_inv[k] * fact_inv[n-k] % MOD) % MOD

print((allpair - combo(n, a) - combo(n, b) - 1) % MOD)
Problem p02838 (python)

Fixed submission:
N = int(input())
A_list = list(map(int, input().split()))
MOD = 10**9 + 7

zeros = [0] * 61
ones = [0] * 61

for a in A_list:
    for i, b in enumerate([1 if (a >> j & 1) else 0 for j in range(61)]):
        if b == 1:
            ones[i] += 1
        else:
            zeros[i] += 1

res = 0
for a in A_list:
    twice = 1
    for i, b in enumerate([1 if (a >> j & 1) else 0 for j in range(61)]):
        if b == 1:
            cnt = zeros[i]
            ones[i] -= 1
        else:
            cnt = ones[i]
            zeros[i] -= 1
        res += twice * cnt
        twice *= 2
    res %= MOD
print(res)

Buggy submission (verdict: Runtime Error):
%%time
from functools import reduce
from operator import xor

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

res = 0
for i,Ai in enumerate(A_arr[:-1]):
    res += sum(map(lambda yj: Ai ^ yj, A_arr[i+1:]))
print(res%(10**9 + 7))
Problem p02923 (python)

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

max_cnt = 0
cnt = 0
for i in range(N-1):
    if Hs[i] < Hs[i+1]:
        max_cnt = max(max_cnt, cnt)
        cnt = 0
    else:
        cnt += 1
print(max(max_cnt, cnt))

Buggy submission (verdict: Runtime Error):
N = int(input())
Hs = list(map(int, input().split()))
max_cnt = 0
tmp = 1 if Hs[0] >= Hs[1] else 0
for i in range(1,N):
    if Hs[i-1] < Hs[i]:
        max_cnt = max(max_cnt, tmp)
        tmp = 0
    else:
        tmp += 1
print(max(max_cnt, tmp))
Problem p02936 (python)

Fixed submission:
from collections import deque

N,Q = list(map(int, input().split()))
tre = [[] for _ in range(N)]
val = [0] * N
for i in range(N-1):
    a,b = list(map(int, input().split()))
    tre[a-1].append(b-1)
    tre[b-1].append(a-1)

for i in range(Q):
    p,x = list(map(int, input().split()))
    val[p-1] += x

stack = deque([0])
visited = [False] * N
visited[0] = True
while stack:
    cur = stack.pop()
    for target in tre[cur]:
        if visited[target]:
            continue
        visited[target] = True
        stack.append(target)
        val[target] += val[cur]

print(*val)

Buggy submission (verdict: Runtime Error):
N,Q = list(map(int, input().split(" ")))
v_list = [0 for _ in range(N)] # n-1でやること注意
dic_tree = {}
for i in range(N):
    dic_tree[i+1] = [] 

for i in range(N-1):
    a, b = list(map(int, input().split(" ")))
    dic_tree[a].append(b)

# make tree
for k in reversed(range(N)):
    if len(dic_tree) == 0:
        continue
    
    for node in dic_tree[k+1]:
        dic_tree[k+1].extend(dic_tree[node])
        
# add 1 
dic_tree[1].append(1)
    
for i in range(Q):
    p, x = list(map(int, input().split(" ")))
    
    for i in dic_tree[p]:
        v_list[i-1] += x

print(" ".join(map(str, v_list))
Problem p03241 (python)

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

maxi = 1
for i in range(int(M**0.5), 0, -1):
    if M % i != 0:
        continue
    if M//i >= N:
        maxi = max(maxi, i)
    if i >= N:
        maxi = max(maxi, M//i)

print(maxi)

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

for i in range(int(M**0.5), 1, -1):
    if M % i != 0:
        continue
    if M//i >= N:
        break

print(i)
Problem p03274 (python)

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

lpos = 0
rpos = K-1

near = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])
bet = abs(xlist[lpos] - xlist[rpos])

ans = bet + near

for i in range(N-K):
    lpos += 1
    rpos += 1

    near = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])
    bet = abs(xlist[lpos] - xlist[rpos])

    tmp = bet+near

    if tmp < ans:
        ans = tmp


print(ans)

Buggy submission (verdict: Runtime Error):

near = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])
bet = abs(xlist[lpos] - xlist[rpos])

ans = bet + near

for i in range(N-K):
    lpos += 1
    rpos += 1

    near = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])
    bet = abs(xlist[lpos] - xlist[rpos])

    tmp = bet+near

    if tmp < ans:
        ans = tmp


print(ans)
Problem p03282 (python)

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

ones = 0
for st in S:
    if st != '1':
        break
    else:
        ones += 1

if K-1 < ones:
    print('1')
else:
    print(S[ones])

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

ones = 0
for st in S:
    if st != '1':
        break
    else:
        ones += 1

if K < ones:
    print('1')
else:
    print(S[ones])

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

ones = 0
for st in S:
    if st != '1':
        break
    else:
        ones += 1

if K < ones:
    print('1')
else:
    print(S[ones])
Problem p03425 (python)

Fixed submission:
N = int(input())
dic = {}
for c in "MARCH":
    dic[c] = 0
myset = set(list("MARCH"))
for _ in range(N):
    c = input()[0]
    if c in myset:
        dic[c] += 1

res = 0
for i in range(5-2):
    for j in range(i+1, 5-1):
        for k in range(j+1, 5):
            res += dic["MARCH"[i]] * dic["MARCH"[j]] * dic["MARCH"[k]]
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
dic = {}
for c in "MARCH":
    dic[c] = 0
myset = set(list("MARCH"))
for _ in range(N):
    c = input()[0]
    if c in myset:
        dic[c] += 1

res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            res += dic["MARCH"[i]] * dic["MARCH"[j]] * dic["MARCH"[k]]
print(res)
Problem p03434 (python)

Fixed submission:
N = int(input())
A_list = sorted(list(map(int, input().split())))[::-1]
a_sum = 0
b_sum = 0

for i in range(N):
    if i % 2 == 0:
        a_sum += A_list[i]
    else:
        b_sum += A_list[i]
print(a_sum - b_sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
A_list = list(map(int, input().split())
 
a_sum = 0
b_sum = 0
for i in range(N//2):
  a,b = (A_list[2*i], A_list[2*i + 1]) if A_list[2*i] > A_list[2*i + 1] else (A_list[2*i + 1], A_list[2*i])
  a_sum += a
  b_sum += b
 
print(a_sum - b_sum)

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

a_sum = 0
b_sum = 0
for i in range(N//2):
  a,b = (A_list[2*i], A_list[2*i + 1]) if A_list[2*i] > A_list[2*i + 1] else (A_list[2*i + 1], A_list[2*i])
  a_sum += a
  b_sum += b

print(a_sum - b_sum)
Problem p03436 (python)

Fixed submission:
from collections import deque

H,W = list(map(int, input().split()))
S = [input() for _ in range(H)]
dist = [[0] * W for i in range(H)]
dist[0][0] = 1

whites = 0
for s in S:
    for w in s:
        if w == ".":
            whites += 1

# Pythonの再帰はおっっそい. 再帰が今回のケースだと使いにくい(探索打ち切り)
def BFS(cur):
    #global dist
    x_path = [-1,0,1,0]
    y_path = [0,-1,0,1]

    q = deque()
    q.append(cur)
    while True:
        if len(q) == 0:
            break
        cur = q.popleft()
        if cur == (H,W):
            break

        for x,y in zip(x_path, y_path):
            nex = (cur[0] + x, cur[1] + y)
            if nex[0] < 1 or nex[0] > H or nex[1] < 1 or nex[1] > W:
                continue
            if S[nex[0]-1][nex[1]-1] == "#":
                continue
            if dist[nex[0]-1][nex[1]-1] > 0:
                continue

            dist[nex[0]-1][nex[1]-1] = dist[cur[0]-1][cur[1]-1] + 1 
            q.append(nex)


BFS((1,1))
if dist[H-1][W-1] == 0:
    print(-1)
else:
    print(whites - dist[H-1][W-1])

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

H,W = list(map(int, input().split()))
S = [input() for _ in range(H)]
dist = [[0] * W for i in range(H)]
dist[0][0] = 1

whites = 0
for s in S:
    for w in s:
        if w == ".":
            whites += 1

# Pythonの再帰はおっっそい. 再帰が今回のケースだと使いにくい(探索打ち切り)
def BFS(cur):
    #global dist
    x_path = [-1,0,1,0]
    y_path = [0,-1,0,1]

    q = deque()
    q.append(cur)
    while True:
        cur = q.popleft()
        if cur == (H,W):
            break

        for x,y in zip(x_path, y_path):
            nex = (cur[0] + x, cur[1] + y)
            if nex[0] < 1 or nex[0] > H or nex[1] < 1 or nex[1] > W:
                continue
            if S[nex[0]-1][nex[1]-1] == "#":
                continue
            if dist[nex[0]-1][nex[1]-1] > 0:
                continue

            dist[nex[0]-1][nex[1]-1] = dist[cur[0]-1][cur[1]-1] + 1 
            q.append(nex)


BFS((1,1))

print(whites - dist[H-1][W-1])
Problem p03544 (python)

Fixed submission:
N = int(input())
L0 = 2
L1 = 1
if N == 1:
    print(L1)
    exit()

for i in range(1,N):
    res = L0 + L1
    L0 = L1
    L1 = res

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
L0 = 2
L1 = 1
if N == 1:
    print(L1)

for i in range(1,N):
    res = L0 + L1
    L0 = L1
    L1 = res

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
L0 = 2
L1 = 1

for i in range(1,N):
    res = L0 + L1
    L0 = L1
    L1 = res

print(res)
Problem p03559 (python)

Fixed submission:
import bisect

N = int(input())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

cnt = 0
for b in Bs:
    a_b = bisect.bisect_left(As,b)
    b_c = N - bisect.bisect_right(Cs, b)
    
    cnt += a_b * b_c
print(cnt)

Buggy submission (verdict: Runtime Error):
import bisect

N = int(input())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

# BとCのセットだけ見てありえるパターンを出す
# B_Csは注目要素より右側の和
B_Cs = [0] * N

prev = N - bisect.bisect_left(Cs, Bs[-1])
B_Cs[-1] = prev
for i, b in enumerate(reversed(Bs)):
    if i == 0 :
        continue
    rev_i = N - i -1
    index = bisect.bisect_left(Cs, b+1)
    
    prev = (N - index) + prev
    B_Cs[rev_i] = prev

cnt = 0
for i, a in enumerate(As):
    index = bisect.bisect_left(Bs, a+1)
    cnt += B_Cs[index]
print(cnt)

Buggy submission (verdict: Runtime Error):
import bisect

N = int(input())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))
Cs = sorted(list(map(int, input().split())))

# BとCのセットだけ見てありえるパターンを出す
B_Cs = [0] * N
for i, b in enumerate(Bs):
    index = bisect.bisect_left(Cs, b+1)
    B_Cs[i] = (N - index)

cumsum_BC =[sum(B_Cs[i:]) for i in range(N)]

cnt = 0
for i, a in enumerate(As):
    index = bisect.bisect_left(Bs, a+1)
    cnt += cumsum_BC[index]
print(cnt)
Problem p03575 (python)

Fixed submission:
N, M = list(map(int, input().split()))
lines = [list(map(int, input().split())) for _ in range(M)]

graph = [[False] * N for _ in range(N)]
for a,b in lines:
    graph[a-1][b-1] = graph[b-1][a-1] = True

visited = [False for _ in range(N)]

def DFS(v):
    visited[v] = True
    for from_v in range(N):
        if not graph[v][from_v]:
            continue
        if visited[from_v]:
            continue
        DFS(from_v)
    
cnt = 0
for i in range(M):
    pass_a, pass_b = lines[i]
    pass_a -= 1
    pass_b -= 1
    graph[pass_a][pass_b] = graph[pass_b][pass_a] = False
    DFS(pass_a)
    
    cnt += 1 if False in visited else 0
    
    visited = [False for _ in range(N)]
    graph[pass_a][pass_b] = graph[pass_b][pass_a] = True

print(cnt)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
lines = [list(map(int, input().split())) for _ in range(M)]

graph = [[False] * N for _ in range(N)]
for a,b in lines:
    graph[a-1][b-1] = graph[b-1][a-1] = True

visited = [False for _ in range(N)]

def DFS(v):
    visited[v] = True
    for from_v in range(N):
        if not graph[v][from_v]:
            continue
        if visited[from_v]:
            continue
        DFS(from_v)
    
cnt = 0
for i in range(M):
    pass_a, pass_b = lines[i]
    pass_a -= 1
    pass_b -= 1
    graph[pass_a][pass_b] = graph[pass_b][pass_a] = False
    DFS(i)
    
    cnt += 1 if False in visited else 0
    
    visited = [False for _ in range(N)]
    graph[pass_a][pass_b] = graph[pass_b][pass_a] = True

print(cnt)
Problem p03633 (python)

Fixed submission:
# a < b
def gcd(a,b):
    if b % a == 0:
        return a
    return gcd(b % a, a)

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

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

ret = 1
for t in T:
    ret = lcm(ret, t)
print(ret)

Buggy submission (verdict: Runtime Error):
# a < b
def gcd(a,b):
    if b % a == 0:
        return a
    return gcd(b % a, a)

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

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

ret = 1
for t in T:
    ret = lcm(ret, t)
print(ret)
Problem p03994 (python)

Fixed submission:
S = input()
K = int(input())
z = ord('z') + 1

res = ""
flg = False
for i,c in enumerate(S):
    if c == 'a':
        res += 'a'
        continue
    elif z - ord(c) <= K:
        res += 'a'
        K -= z-ord(c)
    else:
        res += chr(ord(c))

res = res[:-1] + chr((ord(res[-1])-ord('a') + K) % 26 + ord('a'))
print(res)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
z = ord('z') + 1

res = ""
flg = False
for i,c in enumerate(S):
    if z - ord(c) <= K:
        res += 'a'
        K -= z-ord(c)
    else:
        res += chr(ord(c))

res = res[:-1] + chr(ord(res[-1]) + K)
print(res)
Problem p02555 (python)

Fixed submission:
from itertools import accumulate

S = int(input())
mod = 10**9 + 7
if S == 1 or S == 2:
    print(0)
    exit()
dp = [0] * (S + 1)
dp[0] = 1
ans = 0
for i in range(S):
    cum = list(accumulate(dp))
    for j in range(S, 2, -1):
        dp[j] = cum[j-3] % mod
    dp[0] = dp[1] = dp[2] = 0
    ans = (ans + dp[S]) % mod
print(ans)

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

S = int(input())
mod = 10**9 + 7
dp = [0] * (S + 1)
dp[0] = 1
ans = 0
for i in range(S):
    cum = list(accumulate(dp))
    for j in range(S, 2, -1):
        dp[j] = cum[j-3] % mod
    dp[0] = dp[1] = dp[2] = 0
    ans = (ans + dp[S]) % mod
print(ans)