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

Fixed submission:
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,max):
        fac[i] = fac[i-1]*i%mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod

def COM(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k]*finv[n-k]%mod)%mod

mod = 10**9+7

K = int(input())
S = input()
N = len(S)
max = N+K
fac = [0] * max
finv = [0] * max
inv = [0] * max
COMinit()
modlist1 = []
modlist2 = []
a = 1
b = 1
for i in range(K+1):
    modlist1.append(a)
    modlist2.append(b)
    a = a*26%mod
    b = b*25%mod

ans = 0
for i in range(K+1):
    x = COM(N+K-i-1,N-1)
    y = modlist1[i]
    z = modlist2[K-i]
    xyz = ((x*y%mod)*z)%mod
    ans = (ans+xyz)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,max):
        fac[i] = fac[i-1]*i%mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod

def COM(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k]*finv[n-k]%mod)%mod

mod = 10**9+7

K = int(input())
S = input()
N = len(S)
max = N+K
fac = [0] * max
finv = [0] * max
inv = [0] * max
COMinit()

ans = 0
for i in range(K+1):
    x = COM(N+K-i-1,N-1)
    y = mod(26,i,mod)
    z = mod(25,K-i,mod)
    xyz = ((x*y%mod)*z)%mod
    ans = (ans+xyz)%mod
print(ans)
Problem p02660 (python)

Fixed submission:
import math
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1

    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1:
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

def get_prime(number):
    prime_list = []
    search_list = list(range(2,number + 1))
    while search_list[0] <= math.sqrt(number):
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        search_list = [num for num in search_list if num % head_num != 0]
    prime_list.extend(search_list)
    return prime_list

l = get_prime(10**6+10)
N = int(input())
ans = 0
k = 1
i = 0
l2 = []
while(l[i]**2 <= N):
    if N % (l[i]**k) == 0:
        N //= (l[i]**k)
        l2.append(l[i]**k)
        k += 1
        ans += 1
    else:
        i += 1
        k = 1
index = 0
while(index < len(l2)):
    if N % (l2[index]) == 0:
        N //= l2[index]
    else:
        index += 1
if is_prime3(N) and N not in l2:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math

def get_prime(number):
    prime_list = []
    search_list = list(range(2,number + 1))
    while search_list[0] <= math.sqrt(number):
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        search_list = [num for num in search_list if num % head_num != 0]
    prime_list.extend(search_list)
    return prime_list

l = get_prime(10**6)
N = int(input())
ans = 0
k = 1
i = 0
while(l[i]**2 <= N):
    if N % (l[i]**k) == 0:
        N //= (l[i]**k)
        k += 1
        ans += 1
    else:
        i += 1
        k = 1
if N != 1 and l[i]!=N:
    ans += 1
print(ans)
Problem p02678 (python)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v,prev = -1):
    for u in graph[v]:
        if u == prev:
            continue
        sign[u] = v
        dfs(u,v)

def bfs(v):
    que = deque([])
    que.append(v)
    while que:
        p = que.popleft()
        if visited[p] == 0:
            visited[p] = 1
            for u in graph[v]:
                que.append(u)

import heapq

def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * (N+1) # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for u in graph[v]:
            tmp = 1 + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                path[u] = v
                heapq.heappush(hq, (tmp, u))
    return path

N,M = map(int,input().split())
graph = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
path = [0]*(N+1)
c = dijkstra(1)
print("Yes")
for i in range(2,N+1):
    print(c[i])

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1]

def dfs(v,prev = -1):
    for u in graph[v]:
        if u == prev:
            continue
        sign[u] = v
        dfs(u,v)

def bfs(v):
    que = deque([])
    que.append(v)
    while que:
        p = que.popleft()
        if visited[p] == 0:
            visited[p] = 1
            for u in graph[v]:
                que.append(u)

import heapq

def dijkstra(s):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * (M+1) # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for u in graph[v]:
            tmp = 1 + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                path[u] = v
                heapq.heappush(hq, (tmp, u))
    return path

N,M = map(int,input().split())
graph = [[] for i in range(M+1)]
for i in range(M):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
path = [0]*(N+1)
c = dijkstra(1)
print("Yes")
for i in range(2,N+1):
    print(c[i])
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next , now)

dfs(0)
print(*point)

Buggy submission (verdict: Runtime Error):
def dfs(v,prev = -1):
    for u in graph[v]:
        if u == prev:
            continue
        point[u] += point[v]
        dfs(u,v)

N, Q = list(map(int,input().split()))
graph = [[] for _ in range(N)]
point = [0]*N

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

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

dfs(0)
print(*point)
Problem p03436 (python)

Fixed submission:
from collections import deque

def bfs():
    # たどり着くまでにかかった回数をいれる多重リスト。
    d = [[float("inf")] * w for i in range(h)]
    # 1ノード降りるときにforで回せるようリスト化しておく
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    # 接したポイントを取り込む用のqueを定義
    que = deque([])
    # スタート地点をqueに加える。探索の際はqueから取り出すループを回すので最初だけ先に入れておく
    que.append((sx,sy))
    # スタートからスタートにかかる距離は0なのでinfを0にかえる。
    d[sx][sy] = 0
    # queがあるかぎり続ける
    while que:
        p = que.popleft()
        # 取り出した点がゴールなら終了
        if p[0] == gy and p[1] == gx:
            break
        #　それ以外の時は，接している点を4方向順に取得。一つずつ処理する。
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            # 新しく取得した座標に対しての処理
            # 迷路内に存在する座標であり，壁ではなく，まだ通ったことがなくdがinfの点なら処理する = 新しく取得した道候補の1つ
            if 0 <= nx < h and 0 <= ny < w and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 道候補をqueに加える。
                que.append((nx, ny))
                # その道候補への経路までにかかった経路をdに加える。
                d[nx][ny] = d[p[0]][p[1]] + 1
    return d[gx][gy]

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h - 1, w - 1

white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            white += 1

res = bfs()
if 0 < res < float("inf"):
    # 白いマスの数から最短経路でかかるコスト分を引く
    # ゴールを黒いマスに変えることはできないためその分も引く
    print(white - res - 1)
else:
    print(-1)

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

def bfs():
    # たどり着くまでにかかった回数をいれる多重リスト。
    d = [[float("inf")] * w for i in range(h)]
    # 1ノード降りるときにforで回せるようリスト化しておく
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    # 接したポイントを取り込む用のqueを定義
    que = deque([])
    # スタート地点をqueに加える。探索の際はqueから取り出すループを回すので最初だけ先に入れておく
    que.append(sx,sy)
    # スタートからスタートにかかる距離は0なのでinfを0にかえる。
    d[sx][sy] = 0
    # queがあるかぎり続ける
    while que:
        p = que.popleft()
        # 取り出した点がゴールなら終了
        if p[0] == gy and p[1] == gx:
            break
        #　それ以外の時は，接している点を4方向順に取得。一つずつ処理する。
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            # 新しく取得した座標に対しての処理
            # 迷路内に存在する座標であり，壁ではなく，まだ通ったことがなくdがinfの点なら処理する = 新しく取得した道候補の1つ
            if 0 <= nx < r and 0 <= ny < c and maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                # 道候補をqueに加える。
                que.append((nx, ny))
                # その道候補への経路までにかかった経路をdに加える。
                d[nx][ny] = d[p[0]][p[1]] + 1
    return d[gy][gx]

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h - 1, w - 1

white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            white += 1

res = bfs()
if 0 < res < float("inf"):
    # 白いマスの数から最短経路でかかるコスト分を引く
    # ゴールを黒いマスに変えることはできないためその分も引く
    print(white - res - 1)
else:
    print(-1)
Problem p03160 (python)

Fixed submission:
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
sys.setrecursionlimit(10**7)
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
def mcost(arr,n,dp):
    if n==1:return 0
    if dp[n]!=-1:return dp[n]
    if n==2:
        dp[n]=abs(arr[1]-arr[0])
        return dp[n]
    elif n==3:
        dp[n]=abs(arr[0]-arr[2])
        return dp[n]
    else:
        dp[n]=min(abs(arr[n-1]-arr[n-2])+mcost(arr,n-1,dp),abs(arr[n-1]-arr[n-3])+mcost(arr,n-2,dp))
        return dp[n]


try:
    for _ in range(1):
        n=int(input())
        arr=[int(i) for i in input().split()]
        dp=[-1]*(n+1)
        print(mcost(arr,n,dp))
    
except EOFError as e:
    print(e)

Buggy submission (verdict: Runtime Error):
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
def mcost(arr,n,dp):
    if n==1:return 0
    if dp[n]!=-1:return dp[n]
    if n==2:
        dp[n]=abs(arr[1]-arr[0])
        return dp[n]
    elif n==3:
        dp[n]=abs(arr[0]-arr[2])
        return dp[n]
    else:
        dp[n]=min(abs(arr[n-1]-arr[n-2])+mcost(arr,n-1,dp),abs(arr[n-1]-arr[n-3])+mcost(arr,n-2,dp))
        return dp[n]


try:
    for _ in range(1):
        n=int(input())
        arr=[int(i) for i in input().split()]
        dp=[-1]*(n+1)
        print(mcost(arr,n,dp))
    
except EOFError as e:
    print(e)

Buggy submission (verdict: Runtime Error):
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
def mcost(arr,n,dp):
    if n==1:return 0
    if dp[n]!=-1:return dp[n]
    elif n==2:
        dp[n]=abs(arr[1]-arr[0])
        return dp[n]
    elif n==3:
        dp[n]=abs(arr[0]-arr[2])
        return dp[n]
    else:
        dp[n]=min(abs(arr[n-1]-arr[n-2])+mcost(arr,n-1,dp),abs(arr[n-1]-arr[n-3])+mcost(arr,n-2,dp))
        return dp[n]


try:
    for _ in range(1):
        n=int(input())
        arr=[int(i) for i in input().split()]
        dp=[-1]*(n+1)
        print(mcost(arr,n,dp))
    
except EOFError as e:
    print(e)
Problem p02639 (python)

Fixed submission:
#!/usr/bin/env python3

a = list(map(int, input().split()))
print(a.index(0) + 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

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

# a + b = X
# 2a + 4b = Y
# --
# b = (Y-2X) / 2

b = (Y - 2 * X) / 2.0
a = X - b

if a.is_integer() and b.is_integer() and a >= 0 and b >= 0:
    print("Yes")
else:
    print("No")
Problem p02924 (python)

Fixed submission:
#!/usr/bin/env python3

N = int(input())
print(N * (N - 1) // 2)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

N = int(input())
l = list(range(2, N + 1)) + [1]
print(sum([i % x for i, x in enumerate(l, start=1)]))
Problem p02641 (python)

Fixed submission:
# C - Forbidden List

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

t = -100
a = [0]*300
for p in P:
    a[100+p-1] = 1

d = 0
while True:
    if a[100+x-1-d] == 0:
        t = x-d
        break
    elif a[100+x-1+d] == 0:
        t = x + d
        break
    else:
        d += 1

print(t)

Buggy submission (verdict: Runtime Error):
# C - Forbidden List

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

t = -100
a = [0]*100
for p in P:
    a[p-1] = 1

d = 0
while True:
    if a[x-1-d] == 0:
        t = x-d
        break
    elif a[x-1+d] == 0:
        t = x + d
        break
    else:
        d += 1

print(t)
Problem p02573 (python)

Fixed submission:
def find_par(x,p):
    
    try :
        if x == p[x] :
            return x

        p[x] = find_par(p[x],p)
        return p[x]
    except:
        return x


def union(x,y,p,size):
    try:
        xp = find_par(x,p)
        yp= find_par(y,p)

        if xp != yp:
            p[yp] = xp
            size[xp] += size[yp]
    except:
        pass
    
n,m=[int(c) for c in input().split()]
p=[i for i in range(n+1)]
size =[1 for i in range(n+1)]
for i in range(m):
    a,b =[int(c) for c in input().split()]
    union(a,b,p,size)

roots= set()

for i in range(1,n+1):
    par = find_par(i,p)
    roots.add(par)

ans = float("-inf")
for pp in roots:
    try:
        ans = max(ans,size[pp])
    except:
        pass

print(ans)

Buggy submission (verdict: Runtime Error):
def find_par(x,p):
    if x == p[x] :
        return x

    p[x] = find_par(p[x],p)
    return p[x]


def union(x,y,p,size):
    xp = find_par(x,p)
    yp= find_par(y,p)

    if xp != yp:
        p[yp] = xp
        size[xp] += size[yp]
    
    
n,m=[int(c) for c in input().split()]
p=[i for i in range(n+1)]
size =[1 for i in range(n+1)]
for i in range(m):
    a,b =[int(c) for c in input().split()]
    union(a,b,p,size)

roots= set()

for i in range(1,n+1):
    par = find_par(i,p)
    roots.add(par)

ans = float("-inf")
for pp in roots:
    ans = max(ans,size[pp])

print(ans)
Problem p02606 (python)

Fixed submission:
L,R,d=[int(c) for c in input().split()]
ans=0
for i in range(L,R+1):
    if i%d == 0:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
def mpow(a,b,m):
    ans=1
    while b >0 :
        if b&1:
            ans = (ans*a)%m
        a=(a*a)%m
        b=b>>1

    return ans

def calcmod(X,m,N):
    mod=0
    for i in range(N+1):
        if X&(1<<i) > 0:
            mod += mpow(2,i,m)
            mod%=m
    return mod

def popcount(m):
    return bin(m).count("1")


def findsteps(mm):
    cnt=0
    while mm !=0:
        cnt+=1
        mm=mm%popcount(mm)
    return cnt
N=int(input())
X=int(input(),2)

##we need to find X%(m-1) and X%(m+1)
m=popcount(X)
m1=m+1
m2=m-1
firstmod=calcmod(X,m1,N)
if m2 !=0:
    secondmod=calcmod(X,m2,N)
fans=[0 for i in range(N)]
k=0
for i in range(N-1,-1,-1):
    if X & (1<<i) >0:
        ##the bit was set
        ##we need to find X%(m-1) - (2^i)%(m-1)
        if m2 == 0:
            ans=0
        else:
            mm=secondmod - mpow(2,i,m2)
            if mm < 0:
                mm+=m2
            mm=mm%m2
            ans=1+findsteps(mm)
    else:
        mm = firstmod + mpow(2,i,m1)
        mm=mm%m1
        ans=1+findsteps(mm)
    fans[k] = ans
    k+=1
        ##the bit was not set
for i in fans:
    print(i)
Problem p02555 (python)

Fixed submission:
from math import log10

class Mod:
    fac = []
    inv = []
    finv = []
    mod = 0
    def __init__(self,maxi:int ,mod:int):
        self.mod = mod
        self.fac = [1]*maxi
        self.inv = [1]*maxi
        self.finv = [1]*maxi
        for i in range(2,maxi):
            self.fac[i] = self.fac[i - 1]*i%mod
            self.inv[i] = mod - self.inv[mod%i]*(mod//i)%mod
            self.finv[i] = self.finv[i-1]*self.inv[i]%mod


    def com(self,n:int, k:int)->int:
        #return nCk
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n]*(self.finv[k]*self.finv[n-k]%self.mod)%self.mod


def main():
    s = int(input())
    m =  Mod(s,10**9 + 7)
    ans = 0
    for n in range(1,s // 3 + 1):
        if 3*n == s:
            ans = (ans+1)%(10**9 + 7)
            break
        ans = (ans + m.com(-2*n + s - 1,s - 3*n))%(10**9 + 7)
    print(ans)
    return

if __name__ == "__main__":
    main()

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

    class Mod:
        fac = []
        inv = []
        finv = []
        mod = 0
        def __init__(self,maxi:int ,mod:int):
            self.mod = mod
            self.fac = [1]*maxi
            self.inv = [1]*maxi
            self.finv = [1]*maxi
            for i in range(2,maxi):
                self.fac[i] = self.fac[i - 1]*i%mod
                self.inv[i] = mod - self.inv[mod%i]*(mod//i)%mod
                self.finv[i] = self.finv[i-1]*self.inv[i]%mod


        def com(self,n:int, k:int)->int:
            #return nCk
            if n < k:
                return 0
            if n < 0 or k < 0:
                return 0
            return self.fac[n]*(self.finv[k]*self.finv[n-k]%self.mod)%self.mod


    def main():
        s = int(input())
        m =  Mod(s,10**9 + 7)
        ans = 0
        for n in range(1,s // 3 + 1):
            if 3*n == s:
                ans = (ans+1)%(10**9 + 7)
                break
            ans = (ans + m.com(-2*n + s - 1,s - 3*n))%(10**9 + 7)
        print(ans)
        return

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

Fixed submission:
from math import log2

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    if K > log2(N)+ 50:
        return print(*[N]*N,sep = " ")
    for _ in range(K):
        imos = [0]*(N + 1)
        for i in range(N):
            imos[max(0,i  - A[i])] += 1
            imos[min(N,i + 1 + A[i])] -= 1
        for j in range(N):
            imos[j+1] += imos[j]
        A = imos[:N].copy()
    print(*A,sep=" ")
    return

if __name__ == "__main__":
    main()

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

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    if K > log2(N):
        return print(*[N]*N,sep = " ")
    for _ in range(K):
        imos = [0]*(N + 1)
        for i in range(N):
            imos[max(0,i  - A[i])] += 1
            imos[min(N,i + 1 + A[i])] -= 1
        for j in range(N):
            imos[j+1] += imos[j]
            flag += 1 if imos[j] == N else 0
        A = imos[:N].copy()
    print(*A,sep=" ")
    return 

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    flag = 0
    for k in range(K):
        imos = [0]*(N + 1)
        if flag == N:
            print([N]*(N))
            return
        for i in range(N):
            imos[max(0,i  - A[i])] += 1
            imos[min(N + 1,i + 1 + A[i])] -= 1
        for j in range(N):
            imos[j+1] += imos[j]
        A = imos[:N].copy()
    print(*A,sep=" ")
    return 

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

Fixed submission:

def main():
    X = int(input())
    A = [False]*(110000)
    A[100] = True
    A[101] = True
    A[102] = True
    A[103] = True
    A[104] = True
    A[105] = True
    for i in range(100,X+1):
        if A[i]:
            A[i+100] = True
            A[i+101] = True
            A[i+102] = True
            A[i+103] = True
            A[i+104] = True
            A[i+105] = True
    if A[X]:
        print(1)
    else:
        print(0)
    return 

main()

Buggy submission (verdict: Runtime Error):

def main():
    X = int(input())
    A = [False]*(10**5 + 1)
    A[100] = True
    A[101] = True
    A[102] = True
    A[103] = True
    A[104] = True
    A[105] = True
    for i in range(100,X+1):
        if A[i]:
            A[i+100] = True
            A[i+101] = True
            A[i+102] = True
            A[i+103] = True
            A[i+104] = True
            A[i+105] = True
    if A[X]:
        print(1)
    else:
        print(0)
    return 

main()
Problem p02883 (python)

Fixed submission:
from math import ceil

def check(N_:int,S_:list,F_:list,upper:int,K_:int)->bool:
    #A_i > A_j (i < j)
    cnt = 0
    for i in range(N_):
        s = S_[i]
        if s > upper:
            cnt += ceil((s - upper)/F_[i])
            if cnt > K_:
                return False
    return True


def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    F = list(map(int,input().split()))
    A.sort(reverse = True)
    F.sort()
    S = [f*a for f,a in zip(F,A)]
    right = max(S)
    left = -1
    while left + 1 < right:
        mid = (right + left) // 2
        if mid == right:
            break
        if check(N,S,F,mid,K):
            right = mid
        else:
            left = mid
    print(right)
    return

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def check(N_:int,S_:list,F_:list,upper:int,K_:int)->bool:
    #A_i > A_j (i < j)
    cnt = 0
    for i in range(N_):
        s = S_[i]
        if s > upper:
            cnt += ceil((s - upper)/F_[i])
            if cnt > K_:
                return False
        else:
            return True
    return True


def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    F = list(map(int,input().split()))
    A.sort(reverse = True)
    F.sort()
    S = [f*a for f,a in zip(F,A)]
    right = sum(S)
    left = -1
    while left + 1 < right:
        mid = (right + left) // 2
        if mid == right:
            break
        if check(N,S,F,mid,K):
            right = mid
        else:
            left = mid + 1
    print(mid)
    return

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

Fixed submission:
def main():
    N  = int(input())
    ans = (N-1)*N // 2
    print(ans)
    return
main()

Buggy submission (verdict: Runtime Error):
import heapq
a = [6, 3, 2, 4, 5]
heapq.heapify(a)    # 破壊的

print a[0]    # => 2
heapq.heappop(a)    # 最小値をヒープから取り出す
print a[0]    # => 3
heapq.heappush(a, 1)    # ヒープに要素を追加する
print a[0]    # => 1