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

Fixed submission:
S = input()
N = len(S)
ans = [0] * N
i = 0
while i < N:
  if i == N-1:# 一番右はL固定
    ans[N-1] +=1
    break
  count = 1
  while S[i+count] == S[i]:
    count += 1
    if count == N-i:
      break
  if S[i] == 'R':
    ans[i+count-1] += (count+1)//2
    ans[i+count] += count//2
  else:
    ans[i] += (count+1)//2
    ans[i-1] += count//2
  i += count
print(*ans)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = [0] * N
i = 0
while i < N:
  count = 1
  while S[i+count] == S[i]:
    count += 1
    if count == N-1-i:
      break
  if S[i] == 'R':
    ans[i+count] += (count+1)//2
    ans[i+count-1] += count//2
  else:
    ans[i] += (count+1)//2
    ans[i-1] += count//2
  i += count
print(*ans)
Problem p02987 (python)

Fixed submission:
S = input()
S2 = list(set(S))
print('Yes') if len(S2) == 2 and S.count(S2[0]) == S.count(S2[1]) else print('No')

Buggy submission (verdict: Runtime Error):
S = input()
S.sort()
if S[0]==S[1] and S[2]==S[3] and S[1]!=S[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
S2 = set(list(S))
print('Yes') if len(S2) == 2 and S.count(S2[0]) == S.count(S2[1]) else print('No')

Buggy submission (verdict: Runtime Error):
S = input()
print('Yes') if len(set(S)) == 2 and S.count(set(S[0]) == S.count(set(S[1])) else print('No')
Problem p03038 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush,heapify
from bisect import bisect_left

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    q = []
    for i in range(M):
        B, C = map(int, input().split())
        heappush(q,(-C,B))
    
    ans = 0
    index = 0
    # print(A)
    while q:
        c,b = heappop(q)
        c *= -1
        # print(c,b)
        count = 0
        for i in range(b):
            if i + index == N:
                break
            if c > A[index+i]:
                ans += c
                count += 1
            else:
                break

        # print(ans,index)
        if count < b:
            index += count
            break
        else:
            index += count
            
    print(ans + sum(A[index:]))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush,heapify
from bisect import bisect_left

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    q = []
    for i in range(M):
        B, C = map(int, input().split())
        heappush(q,(-C,B))
    
    ans = 0
    index = 0
    # print(A)
    while q:
        c,b = heappop(q)
        c *= -1
        # print(c,b)
        count = 0
        for i in range(b):
            if c > A[index+i]:
                ans += c
                count += 1
            else:
                break

        # print(ans,index)
        if count < b:
            index += count
            break
        else:
            index += count
            
    print(ans + sum(A[index:]))

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

Fixed submission:
print('ABC') if int(input()) < 1000 else print('ABD')

Buggy submission (verdict: Runtime Error):
return "ABC" if int(input()) < 1000 else "ABD"
Problem p03745 (python)

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

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    i = 0
    while 1:
        if i == N:
            break
        # 単調非減少と単調非増加の列の長い方を採用Greedy
        a = i
        while a < N-1 and A[a] <= A[a+1]:
            a += 1
        b = i
        while b < N-1 and A[b] >= A[b+1]:
            b += 1
        i = max(a,b) + 1
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    i = 0
    while 1:
        if A[i] <= A[i+1] <= A[i+2] or A[i] >= A[i+1] >= A[i+2]:
            i += 1
        else:
            ans += 1
            i += 2
        if i > N - 3:
            ans += 1
            break
    print(ans)


if __name__ == '__main__':
    main()

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

ans = 0
i = 0
while i < N-3:
  tmp = i
  while (A[tmp+1]-A[tmp])*(A[tmp+2]-A[tmp+1])>=0:
    tmp += 1
    if tmp == N-3:
      break
  ans += 1 
  i = tmp+2
else:
  if (A[N-2]-A[N-3])*(A[N-1]-A[N-2])>=0:
    ans += 1
  else:
    ans += 2
print(ans)

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

ans = 0
i = 0
while i < N-3:
  tmp = i
  while (A[tmp+1]-A[tmp])*(A[tmp+2]-A[tmp+1])>=0:
    tmp += 1
    if tmp == N-3:
      break
  ans += 1 
  i = tmp+2
else:
  if (A[N-2]-A[N-3])*(A[N-1]-A[N-3])>=0:
    ans += 1
  else:
    ans += 2
print(ans)
Problem p02793 (python)

Fixed submission:
import sys
sys.setrecursionlimit(4100000)
import math




N = int(input())


import fractions
a = list(map(int, input().split()))
koubai = a[0]
small = []
for i in range(0, N//2):
    small.append(a[2*i + 1] * a[2*i] // fractions.gcd(a[2*i + 1], a[2*i]))

small.append(a[-1])
for i in range(len(small)):
    koubai = koubai * small[i] // fractions.gcd(koubai, small[i])


ans = int(0)
for i in range(N):
    ans += koubai // a[i]
    
ans %= 1000000007

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

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

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

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

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

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

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''

N = int(input())
A = list(map(int,input().split()))

common = 1
for i in range(len(A)):
    common = common * a // math.gcd(common, A[i])

ans = 0
for i in range(len(A)):
    ans += common // A[i]
    ans %= MOD

print(ans)
Problem p02815 (python)

Fixed submission:
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''


N = int(input())
C = list(map(int,input().split()))

# コストの小さいものから更新していけばいい
C.sort()

# 2のべき乗は先に計算しておく
beki = [1]
for i in range(1, 3*N+20):
    beki.append((beki[i-1]*2)%MOD)


ans = 0
for i in range(N):
    ans += (C[i] * beki[2*N-2] * (N-i+1))%MOD
    

print(ans % MOD)

Buggy submission (verdict: Runtime Error):
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''


N = int(input())
C = list(map(int,input().split()))

# コストの小さいものから更新していけばいい
C.sort()

# 2のべき乗は先に計算しておく
beki = []
for i in range(3*N+20):
    beki.append(int(math.pow(2, i))%MOD)


ans = 0
for i in range(N):
    ans += (C[i] * beki[2*N-2] * (N-i+1))%MOD
    

print(ans % MOD)

Buggy submission (verdict: Runtime Error):
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''


N = int(input())
C = list(map(int,input().split()))

# コストの小さいものから更新していけばいい
C.sort()

# 2のべき乗は先に計算しておく
beki = []
for i in range(3*N+20):
    beki.append(int(math.pow(2, i)))


ans = 0
for i in range(N):
    ans += (C[i] * beki[2*N-2] * (N-i+1))
    

print(ans % MOD)
Problem p02754 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
ans += n // (a + b) * a
k = n % (a + b)
if k >= a:
  ans += a
else:
  ans += k
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
s = ''
while len(s) < n:
  s += 'b' * a + 'r' * b
print(s[:n].count('b'))
Problem p02831 (python)

Fixed submission:
a, b = map(int, input().split())
ans = 0
if a > b:
  for i in range(1, a + 1):
    if b * i % a == 0:
      ans = b * i
      break
else:
  for i in range(1, b + 1):
    if a * i % b == 0:
      ans = a * i
      break
print(ans)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))
Problem p02881 (python)

Fixed submission:
import math
n = int(input())
l = []
for i in range(1, int(math.sqrt(n)) + 1):
  if n % i == 0:
    a = i
    b = n // i
    l.append(a + b - 2)
print(min(l))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(1, n // 2):
  if n % i == 0:
    l.append(i + n // i - 2)
print(min(l))
Problem p03012 (python)

Fixed submission:
n = int(input())
w = list(map(int, input().split()))
arr = []
for i in range(n):
  a = w[:i]
  b = w[i:]
  arr.append(abs(sum(a) - sum(b)))
print(min(arr))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
ans = 1
for i in range(n):
  d += l[i]
  if d <= x:
    ans += 1
print(ans)
Problem p02723 (python)

Fixed submission:
#author : dokueki

import sys


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    s = input()
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")



if __name__ == "__main__":
    #IOE()
    main()

Buggy submission (verdict: Runtime Error):
#author : dokueki

import sys


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    s = input()
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print(No)



if __name__ == "__main__":
    #IOE()
    main()
Problem p02831 (python)

Fixed submission:
def lcm(a,b):
  lar = max(a, b) 
  small = min(a, b) 
  i = lar 
  while(1) : 
    if (i % small == 0): 
      return i 
    i += lar 

x,y = map(int,input().split())
print(lcm(x,y))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
div = math.gcd(a,b)
pro = a*b
print(pro//div)

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
print((a*b)//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
print((a*b)//math.gcd(a,b))
Problem p02629 (python)

Fixed submission:
n = int(input())
ans = ""
while n != 0:
    n -= 1
    ans += chr(97 + n%26)
    n = n//26
for c in reversed(ans):
    print(c, end="")

Buggy submission (verdict: Runtime Error):
n = int(input())
di = {}
li = []
ans = ""
for i in range(26):
    di[i+1] = chr(i+97)
while n != 0:
    li.append(di[n % 26])
    n = n // 26
for c in reversed(li):
    ans += c
print(ans)
Problem p02916 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i < n-1 and a[i+1] == a[i] + 1:
        ans += c[a[i]-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i < n-1 and a[i+1] == a[i] + 1:
        ans += c[i-1]
print(ans)
Problem p02989 (python)

Fixed submission:
n = int(input())
d_lis = list(map(int,input().split()))
li = sorted(d_lis)
mid = n // 2
print(li[mid] - li[mid-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d_lis = list(map(int,input().split()))
li = sorted(d_lis)
mid = n // 2
print(li[mid] - li[mid-1n = int(input())
d_lis = list(map(int,input().split()))
li = sorted(d_lis)
mid = n // 2
print(li[mid] - li[mid-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d_lis = [int(d) for d in input().split()]
ans = 0
c = 0
li = sorted(li)
for a in set(li):
    if a > li[n // 2] and a <= li[(n // 2) + 1]:
        b = a
        c = 1
if c == 1:
    ans = li[(n // 2) + 1] - b + 1
    print()
Problem p03072 (python)

Fixed submission:
c = 0
n = int(input())
li = list(map(int,input().split()))
li1 = []
for a in li:
    li1.append(a)
    if a >= max(li1):
            c += 1
print(c)

Buggy submission (verdict: Runtime Error):
li1 = []
c = 0
n = int(input())
for i in range(n):
    h = int(input())
    if i == 0:
        c += 1
    else:
        if h >= max(li1):
            c += 1
    li1.append(h)
print(c)
Problem p03137 (python)

Fixed submission:
n, m = map(int, input().split())
li_X = list(map(int, input().split()))

li_X.sort()
li_X_delta = []
for i in range(len(li_X)-1):
    li_X_delta.append(li_X[i+1]-li_X[i])
li_X_delta.sort(reverse=True)
cnt = 0

ans = li_X[-1] - li_X[0]
for i in range(min(n-1, len(li_X_delta))):
    ans -= li_X_delta[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
li_X = list(map(int, input().split()))

if(m==1):
    print(0)

else:
    li_X.sort()

    li_X_delta = []
    for i in range(len(li_X)-1):
        li_X_delta.append(li_X[i+1]-li_X[i])

    li_X_delta_sorted_rev = sorted(li_X_delta, reverse=True)
    path_ignorable = []
    cnt = 0

    for i in range(n-1):
        path_ignorable.append(li_X_delta.index(li_X_delta_sorted_rev[cnt]))
        cnt += 1
    # ignore path from li_X[i] to li_X[i+1] for i in path_ignorable
    
    ans = 0
    for i in range(len(li_X_delta)):
        if(i in path_ignorable):
            continue
        ans += li_X_delta[i]
    print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
li_X = list(map(int, input().split()))

if(m==1):
    print(0)

else:
    li_X.sort()

    li_X_delta = []
    for i in range(len(li_X)-1):
        li_X_delta.append(li_X[i+1]-li_X[i])

    li_X_delta_sorted_rev = sorted(li_X_delta, reverse=True)
    path_ignorable = []
    cnt = 0

    for i in range(n-1):
        path_ignorable.append(li_X_delta.index(li_X_delta_sorted_rev[cnt]))
        cnt += 1
    # ignore path from li_X[i] to li_X[i+1] for i in path_ignorable
    
    ans = 0
    """
    for i in path_ignorable:
        print("from " + str(i) + " to " + str(i+1))
    """
    for i in range(len(li_X_delta)):
        if(i in path_ignorable):
            continue
        ans += li_X_delta[i]
    print(ans)
Problem p03804 (python)

Fixed submission:
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
fl = False
for i in range(n - m + 1):
    if b[0] in a[i]:
        tmp = a[i].find(b[0])
        if m == 1:
            fl = True
        for j in range(1,m):
            if a[i+j][tmp:tmp+m] != b[j]:
                fl = False
                break
            fl = True
    if fl:
        break
if fl:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
b = []
fl = False
for i in range(n):
    a.append(list(input()))
for i in range(m):
    b.append(list(input()))
for i in range(n - m + 1):
    if b[0] in a[i]:
        tmp = a[i].find(b[0])
        if m == 1:
            fl = True
        for j in range(1,m):
            if a[i+j][tmp:tmp+m] != b[j]:
                fl = False
                break
            fl = True
    if fl:
        break
        if fl:
    print("Yes")
else:
    print("No")
Problem p02834 (python)

Fixed submission:
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))
ni = lambda: int(ns())
sys.setrecursionlimit(200000)

(n,u,v)=na()
u -= 1
v -= 1

g = [[] for _ in range(n)]

for i in range(0, n-1):
    (a, b) = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)


dep1 = [0] * n
dep2 = [0] * n
def dfs(now, pre, d, dep):
    dep[now] = d
    for nex in g[now]:
        if pre == nex:
            continue
        dfs(nex,now,d+1,dep)


dfs(u, -1, 0, dep1)
dfs(v, -1, 0, dep2)

ret = 0
for i in range(n):
    if dep1[i] < dep2[i]:
        ret = max(ret, dep2[i]-1)
print(ret)

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))
ni = lambda: int(ns())

(n,u,v)=na()
u -= 1
v -= 1

g = [[] for _ in range(n)]

for i in range(0, n-1):
    (a, b) = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)


dep1 = [0] * n
dep2 = [0] * n
def dfs(now, pre, d, dep):
    dep[now] = d
    for nex in g[now]:
        if pre == nex:
            continue
        dfs(nex,now,d+1,dep)


dfs(u, -1, 0, dep1)
dfs(v, -1, 0, dep2)

ret = 0
for i in range(n):
    if dep1[i] < dep2[i]:
        ret = max(ret, dep2[i]-1)
print(ret)

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
na = lambda: list(map(int, stdin.readline().split()))
ni = lambda: int(ns())

(n,u,v)=na()
u -= 1
v -= 1

g = [[] for _ in range(n)]

for i in range(0, n-1):
    (a, b) = na()
    g[a-1].append(b-1)
    g[b-1].append(a-1)


dep1 = [0] * n
dep2 = [0] * n
def dfs(now, pre, d, dep):
    dep[now] = d
    for nex in g[now]:
        if pre == nex:
            continue
        dfs(nex,now,d+1,dep)


dfs(u, -1, 0, dep1)
dfs(v, -1, 0, dep2)

ret = 0
for i in range(n):
    if dep1[i] < dep2[i]:
        ret = max(ret, dep2[i]-1)
print(ret)
Problem p02570 (python)

Fixed submission:
d,t,s=map(int,input().split())
if s*t>=d:
  print("Yes")
else:
  print("No")

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

import sys
import math
def setwise_coprime(a):
  ans=a[0]
  for i in range(1,n):
    ans=math.gcd(ans,a[i])
  return ans

#エラストテネスのふるい
def create_sieve(n):
  sieve=[0]*(n+1)
  for i in range(2,n+1):
    if sieve[i]==0:
      for j in range(i*i,n+1,i):
        sieve[j]=i
  return sieve

#高速素因数分解
def fast_factorization(n, sieve):
  prime={}
  while n>1:
    p=sieve[n]
    #nが素数の場合
    if p==0:
      prime[n]=prime.get(n,0)+1
      break
    #nが素数ではない場合
    else:
      prime[p]=prime.get(p,0)+1
      n=n//p
  return prime

check=set()
if setwise_coprime(a)==1:
  #素因数のダブリをcheck
  sieve=create_sieve(10**6)
  for i in range(n):
    if a[i]!=1:
      s=fast_factorization(a[i], sieve)
      for i in s:
        if i in check:
          print("setwise coprime")
          sys.exit()
        else:
          check.add(i)
  print("pairwise coprime")    
else:
  print("not coprime")
Problem p02580 (python)

Fixed submission:
h,w,m=list(map(int,input().split()))
s=[]
t=[]

for i in range(m):
  H,W=list(map(int,input().split()))
  s.append(H)
  t.append(W)
  
from collections import Counter
u=Counter(s)
v=Counter(t)
max_u=max(u.values())
max_u_set = set([kv[0] for kv in u.items() if kv[1]==max_u])
max_v=max(v.values())
max_v_set = set([kv[0] for kv in v.items() if kv[1]==max_v])
check=len(max_u_set)*len(max_v_set)

ans=0
for i in range(m):
  if u[s[i]]==max_u and v[t[i]]==max_v:
    ans=ans+1

if check-ans==0:
  print(max_u+max_v-1)
else:
  print(max_u+max_v)

Buggy submission (verdict: Runtime Error):
h,w,m=list(map(int,input().split()))

bom=[[0 for i in range(w+1)] for i in range(h+1)]

for i in range(m):
  h,w=list(map(int,input().split()))
  bom[h][w]=1


from itertools import accumulate
for i in range(h+2):
  bom[i]=list(accumulate(bom[i]))


for i in range(1,h+2):
  for j in range(w+1):
    bom[i][j]=bom[i][j]+bom[i-1][j]

ans=0  
for i in range(1,h+2):
  for j in range(1,w+1):
    
    ans=max(ans,bom[h+1][w]-(bom[i-1][j-1]+bom[i-1][w]-bom[i-1][j]+bom[h][j-1]-bom[i][j-1]+bom[h+1][w]-bom[i][w]-bom[h+1][j]+bom[i][j]))
   
    
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,m=list(map(int,input().split()))

bom=[[0 for i in range(w+1)] for i in range(h+1)]

for i in range(m):
  h,w=list(map(int,input().split()))
  bom[h][w]=1


from itertools import accumulate
for i in range(h+2):
  bom[i]=list(accumulate(bom[i]))


for i in range(1,h+2):
  for j in range(w+1):
    bom[i][j]=bom[i][j]+bom[i-1][j]

ans=0  
for i in range(1,h+2):
  for j in range(1,w+1):
    ans=max(ans,bom[h][w]-(bom[i-1][j-1]+bom[i-1][w]-bom[i-1][j]+bom[h][j-1]-bom[i][j-1]+bom[h][w]-bom[i][w]-bom[h][j]+bom[i][j]))
print(ans)
Problem p02598 (python)

Fixed submission:
#最大の最小値を求める問題は二部探索
#最大の最小値がちょうどokとngの境界になる
#求める値をlとするとその長さに全ての丸太をきるのに必要な回数を数えることができる
#その丸太をきる回数がk回以下であればいい
#絶対にだめ→０　絶対にオッケー→max(a)
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
#丸太をきる回数がk回以下かどうか調べる関数
def check(n):
  cnt=0
  for l in a:
    if l%n==0:
      cnt=cnt+l//n-1
    else:
      cnt=cnt+l//n
  if cnt<=k:
    return True
  else:
    return False
#二部探索  
left=0
right=max(a)
while right-left>1:
  mid=(right+left)//2
  if check(mid):
    right=mid
  else:
    left=mid
print(right)

Buggy submission (verdict: Runtime Error):
#最大の最小値を求める問題は二部探索
#最大の最小値がちょうどokとngの境界になる
#求める値をlとするとその長さに全ての丸太をきるのに必要な回数を数えることができる
#その丸太をきる回数がk回以下であればいい
#絶対にだめ→０　絶対にオッケー→max(a)
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
#丸太をきる回数がk回以下かどうか調べる関数
def check(n):
  cnt=0
  for l in a:
    if l%n==0:
      cnt=cnt+l//n-1
    else:
      cnt=cnt+l//n
  if cnt<=k:
    return True
  else:
    return False
#二部探索  
left=-1
right=max(a)+1
while right-left>1:
  mid=(right+left)//2
  if check(mid):
    right=mid
  else:
    left=mid
print(right)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
a,b=list(map(Decimal,input().split()))
print(int(a*b))

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
a,b=list(map(decimal,input().split()))
print(int(a*b))

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque(A)
 
ans=1
while len(q)>0:
    p=q.popleft()
    ans=ans*p
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)