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

Fixed submission:
import bisect

n, m = map(int, input().split())
a_array = sorted([int(x) for x in input().split()])
bc_array = sorted([[int(x) for x in input().split()] for x in range(m)], key=lambda x: x[1], reverse=True)

# 何枚入れ替えられるか
candidate_replace_cnt = n
for b, c in bc_array:
    if a_array[0] >= c or candidate_replace_cnt < 0:
        break
    for i in range(b):
        a_array.append(c)
    candidate_replace_cnt -= b
a_array.sort(reverse=True)
print(sum(a_array[:n]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a_array = [int(x) for x in input().split()]
d = dict()
for a in a_array:
    d.setdefault(a, 0)
    d[a] += 1
for _ in range(m):
    b,c = map(int, input().split())
    d.setdefault(c, 0)
    d[c] += b
key = sort(d.keys(),reverse=True)
ans = 0
index = 0
while n > 0:
    num = key[index]
    if d[num] >= n:
        ans += num * n
        break
    ans += num * d[num]
    n -= d[num]
    index += 1

print(ans)
Problem p03208 (python)

Fixed submission:
n, k = map(int, input().split())
array = sorted([int(input()) for x in range(n)])
tmp = float("inf")
for i in range(k-1, n):
    tmp = min(tmp, array[i]-array[i-k+1])
print(tmp)

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

h_array = []
for i in range(N):
    tree = int(input())
    h_array.append(tree)

h_array.sort()

#最小値を更新していくので、初期値を無限として設定しておく
result = float("inf")
#indexに注意
for i in range(k - 1, N):
    result = min(result, h_array[i] - h_array[i - k + 1])

print(result)

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

h_array = []
for i in range(N):
    tree = int(input())
    h_array.append(tree)

h_array.sort()

#最小値を更新していくので、初期値を無限として設定しておく
result = float("inf")
#indexに注意
for i in range(k - 1, n):
    result = min(result, h_array[i] - h_array[i - k + 1])

print(result)
Problem p03345 (python)

Fixed submission:
import math

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

if k % 2 != 1:
    if a-b == 0:
        print(0)
    else:
        print(a - b if abs(math.log10(abs(a-b))) <= 18 else "Unfair")
else:
    if a-b == 0:
        print(0)
    else:
        print(b - a if abs(math.log10(abs(a-b))) <= 18 else "Unfair")

Buggy submission (verdict: Runtime Error):
import math

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

if k % 2 != 1:
    print(a - b if abs(math.log10(abs(a-b))) <= 18 else "Unfair")
else:
    print(b - a if abs(math.log10(abs(a-b))) <= 18 else "Unfair")

Buggy submission (verdict: Runtime Error):
import math

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

if k % 2 != 1:
    print(a - b if abs(math.log10(a-b)) <= 18 else "Unfair")
else:
    print(b - a if abs(math.log10(a-b)) <= 18 else "Unfair")
Problem p03745 (python)

Fixed submission:
import sys

n = int(input())
array = [int(x) for x in input().split()]

cnt = 1
if n ==1:
    print(cnt)
    exit()

tmp = array.pop(0)
tmp2 = array.pop(0)
mode = "plus" if tmp2 > tmp else "minus" if tmp2 != tmp else "equal"
tmp = tmp2

for i in array:
    if tmp < i:
        if mode == "minus":
            cnt += 1
            mode = "equal"
        elif mode == "equal":
            mode = "plus"
    elif tmp > i:
        if mode == "plus":
            cnt += 1
            mode = "equal"
        elif mode == "equal":
            mode = "minus"
    tmp = i
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
array = [int(x) for x in input().split()]

cnt = 1
tmp = array.pop(0)
tmp2 = array.pop(0)
mode = "plus" if tmp2 > tmp else "minus" if tmp2 != tmp else "equal"
tmp = tmp2

for i in array:
    if tmp < i:
        if mode == "minus":
            cnt += 1
            mode = "equal"
        elif mode == "equal":
            mode = "plus"
    elif tmp > i:
        if mode == "plus":
            cnt += 1
            mode = "equal"
        elif mode == "equal":
            mode = "minus"
    tmp = i
print(cnt)
Problem p03834 (python)

Fixed submission:
a, b, c=map(str, input().split(','))
print(a, b, c)

Buggy submission (verdict: Runtime Error):
a, b, c=map(int, input().split(','))
print(a, b, c)
Problem p03776 (python)

Fixed submission:
import math
def comb(n, k):
    return math.factorial(n) // (math.factorial(n - k) * math.factorial(k))

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

v.sort(reverse=True)
max_avg = sum(v[:a]) / a
min_v = min(v[:a])

ans = 0
for i in range(a, b+1):
    if max_avg != sum(v[:i]) / i: break
    cnt1 = v[:i].count(min_v)
    cnt2 = v.count(min_v)
    ans += comb(cnt2, cnt1)

print(max_avg)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n, a, b = map(int,input().split())
v = list(map(int, input().split()))

v.sort(reverse=True)
max_avg = sum(v[:a]) / a
min_v = min(v[:a])


ans = 0
for i in range(a, b+1):
    if max_avg != sum(v[:i]) / i: break
    cnt1 = v[:i].count(min_v)
    cnt2 = v.count(min_v)
    ans += comb(cnt2, cnt1)

print(max_avg)
print(int(ans))
Problem p03806 (python)

Fixed submission:
import copy
n, ma, mb = map(int, input().split())
a, b, c = [0]*n, [0]*n, [0]*n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())
   
dp = [[float('inf')] * (sum(b)+1) for _ in range(sum(a)+1)]
dp[0][0] = 0
step = set([(0, 0)])

for i in range(n):
    ai, bi = a[i], b[i]

    s = step.copy()
    tempdp = copy.deepcopy(dp)
    for si in s: 
        if dp[si[0]+ai][si[1]+bi] > dp[si[0]][si[1]] + c[i]:
            tempdp[si[0]+ai][si[1]+bi] = dp[si[0]][si[1]] + c[i]
            step.add((si[0]+ai, si[1]+bi))
        
    dp = tempdp[:]
#28 20

ans = float('inf')
for i in range(1, min(sum(a)//ma, sum(b)//mb)+1):
    ans = min(ans, dp[ma*i][mb*i])
    
if ans == float('inf'): print(-1)
else : print(ans)

Buggy submission (verdict: Runtime Error):
n, ma, mb = map(int, input().split())
a, b, c = [0]*n, [0]*n, [0]*n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())
   
dp = [[float('inf')] * (sum(a)+1) for _ in range(sum(b)+1)]
dp[0][0] = 0
step = [(0, 0)]

for i in range(n):
    ai, bi = a[i], b[i]

    s = step.copy()
    for si in s:
        if dp[si[0]+ai][si[1]+bi] > dp[si[0]][si[1]] + c[i]:
            dp[si[0]+ai][si[1]+bi] = dp[si[0]][si[1]] + c[i]
            step.append((si[0]+ai, si[1]+bi))
    
ans = float('inf')
for i in range(1, min(sum(a)//ma, sum(b)//mb)+1):
    ans = min(ans, dp[ma*i][mb*i])
    
if ans == float('inf'): print(-1)
else : print(ans)

Buggy submission (verdict: Runtime Error):
n, ma, mb = map(int, f.readline().split())
a, b, c = [], [], []
for _ in range(n):
    at, bt, ct = map(int, f.readline().split())
    a.append(at)
    b.append(bt)
    c.append(ct)
    
dp = [[float('inf') for _ in range(n*mb + 1)] for _ in range(n*ma + 1)]
dp[0][0] = 0
used = [[0, 0]]

for i in range(n):
    add_used = []
    for at, bt in used:
        if at+a[i] <= n and bt+b[i] <= n:
            if dp[at+a[i]][bt+b[i]] == float('inf'):
                add_used.append([at+a[i], bt+b[i]])
            
            dp[at+a[i]][bt+b[i]] = min(dp[at][bt]+c[i], dp[at+a[i]][bt+b[i]])
        
    used += add_used

if dp[-1][-1] == float('inf'):
    print(-1)
else :
    print(dp[-1][-1])
Problem p02679 (python)

Fixed submission:
N = int(input())
import math
sin_dic = {}
mod = 1000000007

zero_num = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    if a == 0 and b == 0:
        zero_num += 1
        continue
    if a == 0:
        b = -1
    elif b == 0:
        a = 1
    else:
        c = math.gcd(a, b)
        a, b = a//c, b//c
        if a < 0 and b < 0:
            a, b = -a, -b
        elif a < 0 and b > 0:
            a, b = -a, -b
    if (a,b) in sin_dic:
        sin_dic[(a, b)].append(i)
    else:
        sin_dic[(a, b)] = [i]

ans = 1
skip_dic = {}
for (key, _key) , values in sin_dic.items():
    if (key, _key) in skip_dic:
        continue
    oth_len = 0
    norm_len = 0
    norm_len += len(values)
    if (-key, -_key) in sin_dic:
        norm_len += len(sin_dic[(-key, -_key)])
    if (_key, -key) in sin_dic:
        oth_len += len(sin_dic[(_key, -key)])
    if (-_key, key) in sin_dic:
        oth_len += len(sin_dic[(-_key, key)])

    p = pow(2, oth_len, mod) - 1 + pow(2, norm_len, mod)
    ans = (ans * p) % mod
    skip_dic[(key, _key)] = True
    skip_dic[(-key, -_key)] = True
    skip_dic[(_key, -key)] = True
    skip_dic[(-_key, key)] = True
print((ans-1 + zero_num) % mod)

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


def main():
    N, M = list(map(int, input().split()))
    graphs = [[] for i in range(N)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        graphs[a-1].append(b-1)
        graphs[b-1].append(a-1)

    INF = 100000000

    distance = [INF for i in range(N)]
    visited = [False] * N
    #    distance = [[None]*field_x_length]*field_y_length
    visited[0] = True
    distance[0] = 0

    def bfs():
        queue = deque([0])
        distance[0] = 0

        while queue:
            x = queue.popleft()
            for y in graphs[x]:
                if visited[y]:
                    continue
                else:
                    distance[y] = x
                    visited[y] = True
                    queue.append(y)
        return distance

    d = bfs()
    for i in range(N):
        if not visited[i]:
            print("No")
            exit()
    print("Yes")
    for i in range(1, N):
        print(d[i]+1)

if __name__ == "__main__":
    main()
Problem p02699 (python)

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

if W >= S:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import defaultdict

S = input().strip()
l = len(S)
dp = [[0 for _ in range(2019)] for i in range(l)]
for i in range(l):
    s = int(S[i])
    for j in range(2019):
        k = (10 * j + s) % 2019
        dp[i][k] = dp[i-1][j]
    dp[i][s] += 1

ans = 0
for i in range(l):
    ans += dp[i][0]
print(ans)
Problem p03045 (python)

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

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
 
    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
 
    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
 
    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)
 
    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]


uf = UnionFind(N)
for j in range(M):
    x, y, z = list(map(int, input().split()))
    if not uf.is_same(x-1, y-1):
        uf.union(x-1, y-1)

# rootの個数
ans = 0
for i in range(N):
    if i == uf.par[i]:
        ans += 1
print(ans)

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

import numpy as np

arr = np.zeros([N+1,M] ,dtype=int)

for i in range(M):
    x, y, z = list(map(int, input().split()))
    arr[x-1, i] = 1
    arr[y-1, i] = 1
    arr[-1, i ] = z % 2
ml = 0
for j in range(M):
    ml_flag = True
    for i in range(j, N):
        #print(arr[i][j])
        if i == 0 and j == 2:
            import IPython;IPython.embed()
        if arr[i][j] != 0:
            min_i = i
            ml_flag = False
            #print("i,j", i, j, "break")
            break
    if ml_flag:
        ml += 1
    for i in range(min_i+1, N):
        #print("yay")
        #print("arr", arr)
        if arr[i][j] != 0:
            arr[i] = (arr[i] + arr[min_i]) % 2

print(N - M + ml)
Problem p03326 (python)

Fixed submission:
A,M = list(map(int,input().split()))
ans = 0
x = []
y = []
z = []
w = [0 for i in range(A)]
for i in range(A):
    a,b,c = list(map(int,input().split()))
    x.append(a)
    y.append(b)
    z.append(c)
for aa in [1,-1]:
    for bb in [1,-1]:
        for cc in [1,-1]:
            #print(a)
            #print(x)
            tx = [ aa * j for j in x]
            ty = [ bb * j for j in y]
            tz = [ cc * j for j in z]
            for j in range(A):
                w[j] = tx[j] + ty[j] + tz[j]
            tw = sum(sorted(w)[::-1][:M])
            if tw > ans:
                ans = tw
print(ans)

Buggy submission (verdict: Runtime Error):
A,M = list(map(int,input().split()))
x = [0 in range(A)]
y = [0 in range(A)]
z = [0 in range(A)]
w = [0 in range(A)]
ans = 0
for i in range(A):
    x[i],y[i],z[i] = list(map(int,input().split()))
for a in [1,-1]:
    for b in [1,-1]:
        for c in [1,-1]:
            tx = [ a * i for i in range(x)]
            ty = [b * i for i in range(y)]
            tz = [ c * i for i in range(z)]
            for i in range(A):
                w[i] = tx[i] + ty[i] + tz[i]
            tw = sum(sorted(w)[::-1][:M])
            if tw > ans:
                ans = tw
print(ans)
Problem p03327 (python)

Fixed submission:
N = int(input())            
if N > 999:                 
    print("ABD")            
else:                       
    print("ABC")

Buggy submission (verdict: Runtime Error):
N,C = list(map(int,input().split()))
D = [ list(map(int,input().split()))  for i in range(C)]
c = [ list(map(int,input().split()))  for i in range(N)]

sep = {0:[0 for i in range(C)],1:[0 for i in range(C)],2:[0 for i in range(C)]}
for i,cx in enumerate(c):
    for j,cy in enumerate(cx):
        if len(c) == 2 and (i + j) % 3 == 2:
            sep[(i + j) % 3 - 1][cy -1] += 1
        else:
            sep[(i + j) % 3][cy - 1] += 1
minimums = [[],[],[]]
for key,values in sep.items():
    for i in range(C):
        m0 = 0
        am0 = 0
        m1 = 0
        am1 = 1
        deposit = 0
        for j,value in enumerate(values):
            deposit += D[j][i] * valuea
        sep[key].append(deposit)
min0 = min(sep[0])
min1 = min(sep[1])
min2 = min(sep[2])

print(min1 + min2 + min0)

Buggy submission (verdict: Runtime Error):
N = int(input())            
if N > 999:                 
    print("ABD")            
else:                       
    pritn("ABC")
Problem p03332 (python)

Fixed submission:
import math
import sys
import fractions
inp = input()
N,A,B,K = list(map(int,inp.split()))
# g = math.gcd(A,B)
g = fractions.gcd(A,B)
if K % g != 0:
    print(0)
    sys.exit()
A = A // g
B = B // g
K = K // g
xn = []
yn = []
for i in range(10 ** 100):
    if (A * i- K) % B == 0:
        n = i
        xn.append(n)
        yn.append((K - A *n) // B)
        break
if yn[-1] < 0:
    if K % B == 0 and (K // B <= N):
        print(1)
    else:
        print(0)
    sys.exit()
while True:
    x  = xn[-1] + B
    y  = yn[-1] - A
    if y < 0:
        break
    xn.append(x)
    yn.append(y)
ans = 0
P = 998244353
def inv(n):
  return pow(n, P-2, P)
fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i % P
invfact = [inv(fact[N])] * (N+1)
for i in range(N, 0, -1):
  invfact[i-1] = invfact[i] * i % P
def comb(n, k):
  return fact[n] * invfact[k] * invfact[n-k] % P 
 
for x,y in zip(xn,yn):
    if N-x< 0 or N -y < 0:
        continue 
    ans = (ans + (comb(N,x) * comb(N,y))) % P
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
inp = input()
N,A,B,K = list(map(int,inp.split()))
g = math.gcd(A,B)
if K % g != 0:
    print(0)
    sys.exit()
A = A // g
B = B // g
K = K // g
xn = []
yn = []
for i in range(10 ** 100):
    if (A * i- K) % B == 0:
        n = i
        xn.append(n)
        yn.append((K - A *n) // B)
        break
if yn[-1] < 0:
    if K % B == 0 and (K // B <= N):
        print(1)
    else:
        print(0)
    sys.exit()
while True:
    x  = xn[-1] + B
    y  = yn[-1] - A
    if y < 0:
        break
    xn.append(x)
    yn.append(y)
ans = 0
P = 998244353
def inv(n):
  return pow(n, P-2, P)
fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i % P
invfact = [inv(fact[N])] * (N+1)
for i in range(N, 0, -1):
  invfact[i-1] = invfact[i] * i % P
def comb(n, k):
  return fact[n] * invfact[k] * invfact[n-k] % P 
 
for x,y in zip(xn,yn):
    if N-x< 0 or N -y < 0:
        continue 
    ans = (ans + (comb(N,x) * comb(N,y)) % P)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
x = input()
N,A,B,K = list(map(int,x.split()))
g = math.gcd(A,B)
if K % g != 0:
    print(0)
    sys.exit()
A = A // g
B = B // g
K = K // g
xn = []
yn = []
for i in range(10 ** 100):
    if (A * i- K) % B == 0:
        n = i
        xn.append(n)
        yn.append((K - A *n) // B)
        break
if yn[-1] < 0:
    if K % B == 0 and (K // B <= N):
        print(1)
    else:
        print(0)
    sys.exit()
while True:
    x  = xn[-1] + B
    y  = yn[-1] - A
    if y < 0:
        break
    xn.append(x)
    yn.append(y)
ans = 0
P = 998244353
def inv(n):
  return pow(n, P-2, P)
fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i % P
invfact = [inv(fact[N])] * (N+1)
for i in range(N, 0, -1):
  invfact[i-1] = invfact[i] * i % P
def comb(n, k):
  return fact[n] * invfact[k] * invfact[n-k] % P 

for x,y in zip(xn,yn):
    if N-x< 0 or N -y < 0:
        continue 
    ans = (ans + (comb(N,x) * comb(N,y)) % P)
print(ans)
Problem p03346 (python)

Fixed submission:
N = int(input())
dic = {}
nums = []
for i in range(N):
    num = int(input())
    dic[num] = i+1
    nums.append(num)
ans = 0
l = 0
for i in range(N-1):
    if dic[i+2] < dic[i+1]:
        ans = max(ans, l)
        l = 0
    else:
        l += 1
ans = max(ans, l)
print(N-ans-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
dic = {}
nums = []
for i in range(N):
    num = int(input())
    dic[num] = i+1
    nums.append(num)
ans = 0
for i in range(N):
    if nums[i] <= nums[-1]:
        break
#ans += i
base = nums[i]
print(base)
init_num = base
# baseの位置 > base+1の所できる.
move = 0
while base <= nums[-1]:
    old_i = i
    i = dic[base + 1]
    if old_i > i:
        break
    base += 1
    move += 1
#import IPython;IPython.embed()
#if base != nums[-1]:
#    ans += 1
ans += init_num - 1
ans += N - base
#ans += N - nums[-1]
print(ans)


"""
戦略的には
1. a_0 > a_nの時,どちらかをずらす.
a_nを前に持っていくか,a_0を後ろに持っていくか...
どっちでも変わらない.
"""

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
p = [ int(input()) for i in range(n)]
pmin = -1
pmax = n
for i,j in enumerate(p):
    if i + 1 == j:
        continue
    else:
        pmin = i
        break
for i,j in enumerate(p[::-1]):
    if n - i  == j:
        continue
    else:
        pmax = n - i -1
        break


nppma  = np.array(p[:pmax + 1 ],dtype="int32")
nppmi = np.array(p[pmin  :],dtype="int32")
#print(nppmi)
#print(nppma)
nmax = nppma.argmax()
nmin = nppmi.argmin()
#print(nppmi[:nmin])
#print(nppma[nmax +1:])
ansmin =  n  + 1 - np.min(nppmi[:nmin])
ansmax = np.max(nppma[nmax + 1:])
print(min(ansmin,ansmax))
Problem p02793 (python)

Fixed submission:
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
A=list(map(int, input().split()))
L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans = ans + L//a

MOD = 1000000007
print(int(ans)%MOD)

Buggy submission (verdict: Runtime Error):
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
A=list(map(int, input().split()))
L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans = ans + L/a

MOD = 1000000007
print(int(ans)%MOD)

Buggy submission (verdict: Runtime Error):
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

N=int(input())
A=list(map(int, input().split()))
L = 1
for a in A:
    L = lcm(L, a)

ans = 0
for a in A:
    ans = ans + L/a

MOD = 1000000007
print(int(ans)%MOD)
Problem p03075 (python)

Fixed submission:
y = [int(input()) for _ in range(5)]
k = int(input())
if y[4] - y[0] > k:
	print(":(")
	exit(0)
for i in range(4):
	if y[i + 1] - y[i] > k:
		print(":(")
		exit(0)
print("Yay!")

Buggy submission (verdict: Runtime Error):
y = [int(input()) for _ in range(5)]
k = int(input())
if y[4] - y[0] > k:
	print(":(")
	exit(1)
for i in range(4):
	if y[i + 1] - y[i] > k:
		print(":(")
		exit(1)
print("Yay!")

Buggy submission (verdict: Runtime Error):
y = [int(input()) for _ in range(5)]
k = int(input())
for _i, i in enumerate(y):
	for _j in range(_i + 1,4):
		if _j == 5:
			break
		if y[_j] - i > k:
			print(":(")
			exit(1)
print("Yay!")
Problem p02629 (python)

Fixed submission:
N=int(input())
ans=''
while N>0:
  N-=1
  ans+=chr(ord('a')+N%26)
  N//=26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=''
whileN>0:
  N-=1
  ans+=chr(ord('a')+N%26)
  N//=26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=''
whileN>0:
  N-=15
  ans+=chr(ord('a')+N%26)
  N//=26
print(ans[::-1])
Problem p02831 (python)

Fixed submission:
import fractions

A, B = map(int, input().strip().split())
print(A * B // fractions.gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().strip().split())
print(A * B // math.gcd(A,B))
Problem p02859 (python)

Fixed submission:
r = int(input().strip())

print(r**2)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限x
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


X, Y = map(int, input().strip().split())

min_num = min(X,Y)
z = min_num//3

tX = z * 3
tY = z * 3
cA = z
cB = z

rx = X - tX
ry = Y - tY
if rx == 0 and ry == 0:
    print(cmb(cA+cB, cA, mod))
    exit(0)
if rx * 2 == ry:
    cA += rx
elif ry * 2 == rx:
    cB += ry
else:
    raise Exception
    print(0)
    exit(0)
print(cmb(cA+cB, cA, mod))
Problem p02726 (python)

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

import heapq
from collections import defaultdict
cost = defaultdict(list)
for i in range(1, n):
    cost[i-1].append((i, 1))
    cost[i].append((i - 1, 1))
cost[x-1].append((y - 1, 1))
cost[y-1].append((x - 1, 1))

dists = []

for start in range(n):
    d = [float('inf')] * n # 最短距離
    d[start] = 0

    q = [(d[start], start)] # min-heap, (距離, 頂点)
    prev = [None] * n # 経路をたどるときに使う
    heapq.heapify(q)
    while q:
        du, u = heapq.heappop(q) # 最短距離とその頂点
        if d[u] < du:
            continue
        for v, weight in cost[u]:
            if du + weight < d[v]:
                d[v] = du + weight
                prev[v] = u
                heapq.heappush(q, (d[v], v))

    dists.append(d)



from collections import Counter
c = Counter()
for i in range(n):
    for j in range(i+1, n):
        c[dists[i][j]] += 1

for k in range(1, n):
    print(c[k])

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

from collections import defaultdict
g = [[0] * n for _ in range(n)]
for i in range(1, n):
    g[i-1][i] = 1
    g[i][i-1] = 1
g[x-1][y-1] = 1
g[y-1][x-1] = 1

from scipy.sparse.csgraph import floyd_warshall
cost = floyd_warshall(g)

from collections import Counter
c = Counter()
for i in range(n):
    for j in range(i+1, n):
        c[cost[i][j]] += 1

for k in range(1, n):
    print(c[k])