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

Fixed submission:
import sys


sys.setrecursionlimit(10 ** 6)


def f(n):
    if memo[n] > 0:
        return memo[n]
    memo[n] = f(n - 1) + f(n - 2)
    return memo[n]


N, M, *A = map(int, open(0).read().split())
memo = [1, 1] + [-1] * N
A = list(A) + [N + 1]
MOD = 10 ** 9 + 7
ans = 1
prev = 0
for a in A:
    if a == prev:
        ans = 0
        break
    ans *= f(a - 1 - prev)
    ans %= MOD
    prev = a + 1
print(ans)

Buggy submission (verdict: Runtime Error):
def f(n):
    if memo[n] > 0:
        return memo[n]
    memo[n] = f(n - 1) + f(n - 2)
    return memo[n]


N, M, *A = map(int, open(0).read().split())
memo = [1, 1] + [-1] * (N + 10)
A = list(A) + [N + 1]
MOD = 10 ** 9 + 7
ans = 1
prev = 0
for a in A:
    if a == prev:
        ans = 0
        break
    ans *= f(a - 1 - prev)
    ans %= MOD
    prev = a + 1
print(ans)

Buggy submission (verdict: Runtime Error):
def f(n):
    if memo[n] > 0:
        return memo[n]
    else:
        memo[n] = f(n - 1) + f(n - 2)
        return memo[n]


N, M, *A = map(int, open(0).read().split())
memo = [-1] * (N + 2)
memo[0] = 1
memo[1] = 1
A = list(A) + [N + 1]
MOD = 10 ** 9 + 7
ans = 1
prev = 0
for a in A:
    if a == prev:
        ans = 0
        break
    ans *= f(a - 1 - prev)
    ans %= MOD
    prev = a + 1
print(ans)

Buggy submission (verdict: Runtime Error):
def f(n):
    if memo[n] > 0:
        return memo[n]
    else:
        return f(n - 1) + f(n - 2)


N, M, *A = map(int, open(0).read().split())
memo = [-1] * (N + 2)
memo[0] = 1
memo[1] = 1
A = list(A) + [N + 1]
MOD = 10 ** 9 + 7
ans = 1
prev = 0
for a in A:
    if a == prev:
        ans = 0
        break
    ans *= f(a - 1 - prev)
    ans %= MOD
    prev = a + 1
print(ans)
Problem p03329 (python)

Fixed submission:
N = int(input())
dp = [N] * (N + 1)
dp[0] = 0
for i in range(N):
    j = 1
    while i + j <= N:
        dp[i + j] = min(dp[i + j], dp[i] + 1)
        j *= 6
    j = 9
    while i + j <= N:
        dp[i + j] = min(dp[i + j], dp[i] + 1)
        j *= 9
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache


sys.setrecursionlimit(100000)


@lru_cache(maxsize=None)
def rec(n):
    if n == 0:
        return 0
    res = n
    i = 1
    while i <= n:
        res = min(res, rec(n - i) + 1)
        i *= 6
    i = 9
    while i <= n:
        res = min(res, rec(n - i) + 1)
        i *= 9
    return res


N = int(input())
print(rec(N))
Problem p04021 (python)

Fixed submission:
from bisect import bisect_left


N, *A = map(int, open(0).read().split())
sorted_A = sorted(A)
ans = 0
for i in range(N):
    idx = bisect_left(sorted_A, A[i])
    if i % 2 != idx % 2:
        ans += 1
print(ans // 2)

Buggy submission (verdict: Runtime Error):
class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)
        self.k_init = 2 ** (self.n - 1).bit_length()

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & -i


def get_invnum(li):
    n = len(li)
    t = FenwickTree(max(li))
    res = 0
    for i in range(n):
        res += i - t.sum(li[i])
        t.add(li[i], 1)
    return res


N, *A = map(int, open(0).read().split())
triplet_sorted_A = [0] * N
triplet_sorted_A[::2] = sorted(A[::2])
triplet_sorted_A[1::2] = sorted(A[1::2])
print(get_invnum(triplet_sorted_A))
Problem p02594 (python)

Fixed submission:
X=int(input())
if X>=30: print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
import math
N, K=map(int, input().split())
A=list(map(int, input().split()))
i=1
j=10**9
while True:
    k=(i+j)//2
    if k>0 and sum([math.ceil(a/k)-1 for a in A])<=K:
        if k-1>0 and sum([math.ceil(a/(k-1))-1 for a in A])>K:
            print(k)
            break
        else:
            j=k-1
    else:
        i=k+1

Buggy submission (verdict: Runtime Error):
X=int(input())
if X=>30: print('Yes')
else: print('No')
Problem p02598 (python)

Fixed submission:
import math
N, K=map(int, input().split())
A=list(map(int, input().split()))
i=1
j=10**9
while True:
    k=(i+j)//2
    if k>0 and sum([math.ceil(a/k)-1 for a in A])<=K:
        if k==1 or sum([math.ceil(a/(k-1))-1 for a in A])>K:
            print(k)
            break
        else:
            j=k-1
    else:
        i=k+1

Buggy submission (verdict: Runtime Error):
import math
N, K=map(int, input().split())
A=list(map(int, input().split()))
i=1
j=10**9
while True:
    k=(i+j)//2
    if k>0 and sum([math.ceil(a/k)-1 for a in A])<=K:
        if k=1 or sum([math.ceil(a/(k-1))-1 for a in A])>K:
            print(k)
            break
        else:
            j=k-1
    else:
        i=k+1

Buggy submission (verdict: Runtime Error):
import math
N, K=map(int, input().split())
A=list(map(int, input().split()))
i=1
j=10**9
while True:
    k=(i+j)//2
    if k>0 and sum([math.ceil(a/k)-1 for a in A])<=K:
        if k=1 or sum([math.ceil(a/(k-1))-1 for a in A])>K:
            print(k)
            break
        else:
            j=k-1
    else:
        i=k+1

Buggy submission (verdict: Runtime Error):
import math
N, K=map(int, input().split())
A=list(map(int, input().split()))
i=1
j=10**9
while True:
    k=(i+j)//2
    if sum([math.ceil(a/k)-1 for a in A])<=K:
        if k-1>0 and sum([math.ceil(a/(k-1))-1 for a in A])>K:
            print(k)
            break
        else:
            j=k-1
    else:
        i=k+1

Buggy submission (verdict: Runtime Error):
import math
N, K=map(int, input().split())
A=list(map(int, input().split()))
i=1
j=10**9
while True:
    k=(i+j)//2
    if sum([math.ceil(a/k)-1 for a in A])<=K:
        if sum([math.ceil(a/(k-1))-1 for a in A])>K:
            print(k)
            break
        else:
            j=k-1
    else:
        i=k+1

Buggy submission (verdict: Runtime Error):
import math
N, K=map(int, input().split())
A=list(map(int, input().split()))
i=1
j=10**9
while True:
    k=(i+j)//2
    if sum([math.ceil(a/k)-1 for a in A])<=K:
        if sum([math.ceil(a/(k-1))-1 for a in A])>K:
            print(k)
            break
        else:
            j=k-1
    else:
        i=k+1

Buggy submission (verdict: Runtime Error):
N, K=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
for _ in range(K):
    print(A)
    l=A.pop(len(A)-1)/2
    print(A)
    i=-1
    j=len(A)-1
    while i<=j:
        print(i,j)
        k=(i+j)//2
        print(k)
        if k==-1:
            A.insert(0, l)
            break
        elif k==len(A)-1:
            A.insert(l)
            break
        elif A[k]<=l and A[k+1]>=l:
            A.insert(k, l)
            A.insert(k, l)
            break
        elif A[k]>l:
            j=k-1
        else:
            i=k+1
print(math.ceil(A[len(A-1)]))
Problem p02793 (python)

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


def lcm(m, n):
    return (m // fractions.gcd(m, n)) * n


mod = 10**9+7
lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(ans % mod)

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


def lcm(m, n):
    return (m // math.gcd(m, n)) * n


mod = 10**9+7
lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(ans % mod)

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


def lcm(m, n):
    return (m // math.gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(int(ans % int(1e9+7)))

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


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


def lcm(m, n):
    return (m // gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(int(ans % (1e9+7)))

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


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


def lcm(m, n):
    return (m / gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc / a[i])
print(int(ans % (1e9+7)))

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


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


def lcm(m, n):
    return (m / gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
lc %= int(1e9+7)
for i in range(N):
    ans += (lc / a[i])
print(int(ans % (1e9+7)))

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


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


def lcm(m, n):
    return (m / gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc / a[i]) % int(1e9+7)
    ans %= int(1e9+7)
print(int(ans))

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


def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)


def lcm(m, n):
    return (m / gcd(m, n)) * n


lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc / a[i]) % int(1e9+7)
    ans %= int(1e9+7)
print(ans)
Problem p02550 (python)

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

count = X
bef = X
_sum = [bef]
dic = {}

for i in range(1, N):
    bef = pow(bef, 2, M)
    if bef in dic:
        posi = dic[bef]
        l = len(_sum) - posi
        plus = sum(_sum[posi:])
        count += plus * ((N - i) // l)
        mod = ((N - i) % l)
        count += sum(_sum[posi:posi + mod])
        break
    else:
        dic.setdefault(bef, i)
        _sum.append(bef)
    count += bef

print(count)

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

count = X
bef = X
_sum = [X]
dic = {X: 1}

for i in range(1, N + 1):
    bef = pow(bef, 2, M)
    if bef in dic:
        posi = dic[bef]
        l = len(_sum) - posi
        plus = _sum[-1] - (_sum[posi - 1] if posi - 1 > 0 else 0)
        count += plus * ((N - i) // l)
        mod = ((N - i) % l)
        count += _sum[posi - 1 + mod] - (_sum[posi - 1] if posi - 1 > 0 else 0)
        break
    else:
        dic.setdefault(bef, i)
        _sum.append(bef + _sum[-1])
    count += bef

print(count)
Problem p02597 (python)

Fixed submission:
N = int(input())

c_list = [s for s in input()]
back = N - 1


def check(forward):
    global back
    for i in range(back, -1, -1):
        if i < forward:
            return -1
        if c_list[i] == "R":
            back = i - 1
            return i
    return -1


count = 0
for i, c in enumerate(c_list):
    if c_list[i] == "W":
        temp = check(i + 1)
        if temp != -1:
            c_list[i] = "R"
            c_list[temp] = "W"
            count += 1
        else:
            break
print(count)

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

c_list = [s for s in input()]
cr = list(reversed(c_list))
back = N - 1


def check(forward):
    global back
    for i in range(back, -1, -1):
        if back < forward:
            return -1
        if c_list[i] == "R":
            back -= 1
            return back + 1


count = 0
for i, c in enumerate(c_list):
    if c_list[i] == "W":
        temp = check(i + 1)
        if temp != -1:
            c_list[i] = "R"
            c_list[temp] = "W"
            count += 1
        else:
            break
print(count)
Problem p02623 (python)

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

A_sum = [0]
B_sum = [0]

for a in A_list:
    A_sum.append(A_sum[-1] + a)

for b in B_list:
    B_sum.append(B_sum[-1] + b)

count = 0
j = M
for i, a in enumerate(A_sum):
    if a > K:
        break
    while B_sum[j] > K - a:
        j -= 1
    if count < i + j:
        count = i + j

print(count)

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

A_sum = [0]
B_sum = [0]

for a in A_list:
    A_sum.append(A_sum[-1] + a)

for b in B_list:
    B_sum.append(B_sum[-1] + b)

count = 0


def solve(i, j):
    global count
    if A_sum[i] + B_sum[j] > K:
        return
    if count < i + j:
        count = i + j
    if i == len(A_sum) - 1 and j == len(B_sum) - 1:
        return
    elif i == len(A_sum) - 1:
        solve(i, j + 1)
    elif j == len(B_sum) - 1:
        solve(i + 1, j)
    else:
        solve(i + 1, j)
        solve(i, j + 1)


solve(0, 0)
print(count)
Problem p02735 (python)

Fixed submission:
h, w = map(int, input().split())
s_list = []  # h, w
dp_dict = {}
for i in range(h):
    s = input()
    temp_list = []
    for temp in s:
        if temp == "#":
            temp_list.append(1)
        else:
            temp_list.append(0)
    s_list.append(temp_list)


def search(x, y, black):
    res = 0
    if (x, y, black) in dp_dict:
        return dp_dict[(x, y, black)]
    if x == w-1 and y == h-1:
        if s_list[y][x] == 1:
            if black:
                res = 0
            else:
                res = 1
        else:
            res = 0
    elif x == w-1:
        if s_list[y][x] == 1:
            if black:
                res = search(x, y+1, True)
            else:
                res = search(x, y+1, True)+1
        else:
            res = search(x, y+1, False)
    elif y == h-1:
        if s_list[y][x] == 1:
            if black:
                res = search(x+1, y, True)
            else:
                res = search(x+1, y, True)+1
        else:
            res = search(x+1, y, False)
    else:
        if s_list[y][x] == 1:
            if black:
                res = min([search(x+1, y, True), search(x, y+1, True)])
            else:
                res = min([search(x+1, y, True), search(x, y+1, True)])+1
        else:
            res = min([search(x+1, y, False), search(x, y+1, False)])
    dp_dict[(x, y, black)] = res
    return res


print(search(0, 0, False))

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = []  # h, w
for i in range(h):
    s += [','.join(input()).split(',')]

cost = [[1 if s[0][0] == '#' else 0 for i in range(w)] for j in range(h)]

for i in range(1, h + w-1):
    for j in range(w if h < w else h):
        if i - j < w and j >= 0 and i - j >= 0:
            if j == 0:
                cost[j][i - j] = cost[j][i - j - 1]
            elif i - j == 0:
                cost[j][i - j] = cost[j - 1][i - j]
            else:
                cost[j][i - j] = cost[j - 1][i - j] if cost[j - 1][i -
                                                                   j] < cost[j][i - j - 1] else cost[j][i - j - 1]

            if s[j][i - j] == '#':
                cost[j][i - j] += 1

print(cost[h - 1][w - 1])
Problem p02771 (python)

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

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

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

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = a[0]
ans = 1
for i in range(1,n):
  if m <= a[i]:
    ans += 1
    m = a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
a.append(int(i) for i in input().split())  
ans = 0
m = a[0]
for i in range(n-1):
  if m <= a[i+1]:
    ans += 1
    m = a[i+1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
a.append(int(i) for i in input().split())  
ans = 0
m = a[0]
for i in range(n-1):
  if m <= a[i+1]:
    ans += 1
    m = a[i+1]
print(ans)
Problem p03221 (python)

Fixed submission:
import copy
n, m = map(int, input().split())
p = [list(map(int, input().split())) for i in range(m)]
dic = {}
q = copy.copy(p)
q.sort(key=lambda x: x[1])
cnt = [0 for i in range(n+1)]
for i in range(m):
    cnt[q[i][0]] += 1
    dic[q[i][1]] = cnt[q[i][0]]
for i in range(m):
    print(str(p[i][0]).zfill(6)+str(dic[p[i][1]]).zfill(6))

Buggy submission (verdict: Runtime Error):
import copy
n, m = map(int, input().split())
p = [list(map(int, input().split())) for i in range(m)]
dic = {}
q = p.copy()
q.sort(key=lambda x: x[1])
cnt = [0 for i in range(n+1)]
for i in range(m):
    cnt[q[i][0]] += 1
    dic[q[i][1]] = cnt[q[i][0]]
for i in range(m):
    print(str(p[i][0]).zfill(6)+str(dic[p[i][1]]).zfill(6))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
p = [list(map(int, input().split())) for i in range(m)]
dic = {}
q = p.copy()
q.sort(key=lambda x: x[1])
cnt = [0 for i in range(n+1)]
for i in range(m):
    cnt[q[i][0]] += 1
    dic[q[i][1]] = cnt[q[i][0]]
for i in range(m):
    print(str(p[i][0]).zfill(6)+str(dic[p[i][1]]).zfill(6))
Problem p02831 (python)

Fixed submission:
import fractions

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

Buggy submission (verdict: Runtime Error):
import math

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

Fixed submission:
import math
N = int(input())

if (N % 2) == 1:
  print(0)
  exit()

total = 0

for i in range(1, 2+int(math.log(10**18, 5))):
  t = 5 ** i * 2
  total += N // t

print(total)

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

if (N % 2) == 1:
  print(0)
  exit()

total = 0

for i in range(1, 2+int(math.log(N, 5))):
  t = 5 ** i * 2
  total += N // t

print(total)
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))
m = 10**9+7

dp = [0 for _ in range(n+1)]
dp[0] = 1
dp[1] = 1
if 1 in a:
  dp[1] = 0

for i in range(2, n+1):
  dp[i] = 0 if i in a else (dp[i-2] + dp[i-1]) % m

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
  if r == 0 or r == n: return 1
  if r == 1: return n
  if (n,r) in nCr: return nCr[(n,r)]
  nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
  return nCr[(n,r)]

def calc(x):
  total = 1
  m = x // 2
  for i in range(1, 1+m):
    t = cmb((x-i), i)
    total += t
  # print((x, total))
  return total

n, m = map(int, input().split())

total = 1
b = int(input())
total *= calc(b-1)

for _ in range(m-1):
  a = int(input())
  t = a - b - 1
  b = a
  if t == 0:
    total = 0
    break
  total *= calc(t)

total *= calc(n-b-1)

print(total % 10000000007)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x: -x[1])
# print(a)
# print(bc)

count = 0
idx = -1
end = False
for b, c in bc:
  if idx + b <= n-1 and a[idx+b] < c:
    count += b * c
    idx += b
  else:
    for i in range(idx+1, idx+1+b):
      if i >= n or end:
        break
      else:
        if a[i] < c:
          count += c
          idx += 1
        else:
          end = True
  # print((idx, count))
  if end:
    break

if idx <= n-2:
  count += sum(a[idx+1:])

print(count)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x: -x[1])
# print(a)
# print(bc)

count = 0
idx = -1
end = False
for b, c in bc:
  if idx + b >= n and a[idx+b] < c:
    count += b * c
    idx += b
  else:
    for i in range(idx+1, idx+1+b):
      if i >= n or end:
        break
      else:
        if a[i] < c:
          count += c
          idx += 1
        else:
          end = True
  # print((idx, count))
  if end:
    break

if idx <= n-2:
  count += sum(a[idx+1:])

print(count)
Problem p03053 (python)

Fixed submission:
from collections import deque

H, W = map(int, input().split())

m = [['X'] * (W+2)]
for i in range(H):
  row = [c for c in input()]
  row.insert(0, 'X')
  row.append('X')
  m.append(row)
m.append(['X'] * (W+2))

q = deque([deque([(i, j) for j in range(1, 1+W) for i in range(1, 1+H) if m[i][j] == '#'])])

cnt = 0
while(True):
  if not q:
    break
  tt = q.popleft()
  nn = deque([])
  for t in tt:
    # left, right, up, down
    for n in ((t[0]-1, t[1]), (t[0]+1, t[1]), (t[0], t[1]-1), (t[0], t[1]+1)):
      if m[n[0]][n[1]] == '.':
        nn.append(n)
        m[n[0]][n[1]] = '#'
  if nn:
    q.append(nn)
  cnt += 1

print(cnt-1)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
m = ['X' + input() + 'X' for i in range(H)]
m.insert(0, 'X' * (W+2))
m.insert(H+1, 'X' * (W+2))
 
cnt = 0
while(True):
  flag = True
  mm = [['X' for i in range(W+2)] for j in range(H+2)]
  for i in range(1, 1+H):
    for j in range(1, 1+W):
      if m[i][j] == '.':
        if m[i+1][j] == '#' or m[i-1][j] == '#' or m[i][j+1] == '#' or m[i][j-1] == '#':
          mm[i][j] = '#'
        else:
          mm[i][j] = '.'
        if flag:
          flag = False
      elif m[i][j] == '#':
        mm[i][j] = '#'
  cnt += 1
  m = mm.copy()
  if flag:
    break
 
print(cnt-1)
Problem p02598 (python)

Fixed submission:
import math,sys
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=10**9+2
while math.ceil(l)<math.floor(r):
  tr=(l+r)/2
  temp=0
  for i in range(n):
    temp+=math.ceil(a[i]/tr)-1
  if temp<=k:
    r=tr
  else:
    l=tr
tr=math.ceil(l)
if tr==0:
  print(1)
  sys.exit()
temp=0
for i in range(n):
  temp+=a[i]//tr
  if a[i]%tr==0:
    temp-=1
if temp<=k:
  print(tr)
else:
  print(tr+1)

Buggy submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=0
r=10**9+2
while math.ceil(l)<math.floor(r):
  tr=(l+r)/2
  temp=0
  for i in range(n):
    temp+=math.ceil(a[i]/tr)-1
  if temp<=k:
    r=tr
  else:
    l=tr
tr=math.ceil(l)
temp=0
for i in range(n):
  temp+=a[i]//tr
  if a[i]%tr==0:
    temp-=1
if temp<=k:
  print(tr)
else:
  print(tr+1)
Problem p02659 (python)

Fixed submission:
import math
a,b=map(str,input().split())
a=int(a)
d=int(b[0])*100+int(b[2])*10+int(b[3])
c=(a*d)//100
if (c+1)*100<=(a*d):
  c+=1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
zerocounter=0
for i in range(n):
  if a[i]==0:
    zerocounter=1
    break
if zerocounter==1:
  print(0)
else:
  ans=1
  for i in range(n):
    ans=ans*a[i]
    if ans>10**18:
      ans=-1
      break
  print(ans)
Problem p02712 (python)

Fixed submission:
import math
N=int(input())
ans=(N*(N+1))/2
ans=ans-3*math.floor(N/3)*(math.floor(N/3)+1)/2
ans=ans-5*math.floor(N/5)*(math.floor(N/5)+1)/2
ans=ans+15*math.floor(N/15)*(math.floor(N/15)+1)/2
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
Nstring=int(input())
ans=(N*(N+1))/2
ans=ans-math.floor(N/3)
ans=ans-math.floor(N/5)
ans=ans+math.floor(N/15)
print(ans)