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

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

lst = set()
num = []
for i in range(1, n + 1):
    lst.add(x), num.append(x)
    x = x ** 2 % m
    if x in lst:
        cnt, idx = i, num.index(x)
        div, mod = divmod(n - cnt, len(num) - idx)
        ans = sum(num[:idx + mod])
        ans += sum(num[idx:]) * (div + 1)
        break
else:
    ans = sum(num)
print(ans)

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

lst, num, frag = set(), [], False
for i in range(1, n + 1):
    lst.add(x), num.append(x)
    x = x ** 2 % m
    if x in lst:
        flag = True
        break

ans = sum(num)
if flag:
    cnt, idx = i, num.index(x)
    div, mod = divmod(n - cnt, len(num) - idx)
print(ans)

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

lst, num, frag = set(), [], False
for i in range(1, n + 1):
    lst.add(x), num.append(x)
    x = x ** 2 % m
    if x in lst:
        flag = True
        break

ans = sum(num)
if flag:
    cnt, idx = i, num.index(x)
    div, mod = divmod(n - cnt, len(num) - idx)
    ans += sum(num[idx:]) * div
print(ans)

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

lst, num, frag = set(), [], False
for i in range(1, n + 1):
    lst.add(x), num.append(x)
    x = x ** 2 % m
    if x in lst:
        flag = True
        break

ans = sum(num)
if flag:
    cnt, idx = i, num.index(x)
    div, mod = divmod(n - cnt, len(num) - idx)
    ans += sum(num[idx:idx + mod])
    ans += sum(num[idx:]) * div
print(ans)

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

lst, num, frag = set(), [], 0
for i in range(1, n + 1):
    lst.add(x), num.append(x)
    x = x ** 2 % m
    if x in lst:
        flag = 1
        break

ans = sum(num)
if flag == 1:
    cnt, idx = i, num.index(x)
    div, mod = divmod(n - cnt, len(num) - idx)
    ans = sum(num[idx:idx + mod])
    ans += sum(num[idx:]) * div
print(ans)

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

lst = set()
num = []
for i in range(1, n + 1):
    lst.add(x), num.append(x)
    x = x ** 2 % m
    if x in lst:
        break
cnt, idx = i, num.index(x)
div, mod = divmod(n - cnt, len(num) - idx)
ans = sum(num[:idx + mod])
ans += sum(num[idx:]) * (div + 1)
print(ans)
Problem p02552 (python)

Fixed submission:
n = int(input())
print(1 if n == 0 else 0)

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

print(1 if x == 0 else 0)

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

print(1 in x == 0 else 0)
Problem p02580 (python)

Fixed submission:
H, W, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]

row, col = [0] * H, [0] * W
for h, w in hw:
    row[h - 1] += 1
    col[w - 1] += 1

rowmax, colmax = max(row), max(col)
cnt = row.count(rowmax) * col.count(colmax)
for h, w in hw:
    if row[h - 1] == rowmax and col[w - 1] == colmax:
        cnt -= 1
print(rowmax + colmax - (cnt == 0))

Buggy submission (verdict: Runtime Error):
H, W, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]

mat = [[0] * W for _ in range(H)]
for h, w in hw:
    mat[h - 1][w - 1] = 1

rowcnt = [sum(row) for row in mat]
colcnt = []
for col in range(W):
    colcnt.append(sum(row[col] for row in mat))

rowmax, colmax = max(rowcnt), max(colcnt)
print(rowmax + colmax - 1)

Buggy submission (verdict: Runtime Error):
H, W, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]

mat = [[0] * W for _ in range(H)]
for h, w in hw:
    mat[h - 1][w - 1] = 1

rowcnt = [sum(row) for row in mat]
colcnt = [sum(row[col] for row in mat) for col in range(W)]

rowmax, colmax = max(rowcnt), max(colcnt)
print(rowmax + colmax - 1)

Buggy submission (verdict: Runtime Error):
H, W, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]

mat = [[0] * W for _ in range(H)]
for h, w in hw:
    mat[h - 1][w - 1] = 1

rowcnt = [sum(row) for row in mat]
colcnt = [sum(row[col] for row in mat) for col in range(W)]

rowmax, colmax = max(rowcnt), max(colcnt)
for r, mat_h in zip(rowcnt, mat):
    for c, mat_hw in zip(colcnt, mat_h):
        if r == rowmax and c == colmax and mat_hw == 0:
            print(rowmax + colmax)
            exit()
print(rowmax + colmax - 1)
Problem p02596 (python)

Fixed submission:
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

num = 7
for i in range(1,10**6):
    if num % k == 0:
        print(i)
        break
    num = (num % k) * 10 + 7

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

# 解説AC
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

num = 1, 7
for i in range(k):
    if num % k == 0:
        print(i+1)
        break
    num = (num % k) * 10 + 7

Buggy submission (verdict: Runtime Error):
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans, num = 1, 7
while 1:
    if num % k == 0:
        print(i)
        break
    ans += 1
    num = num * 10 + 7
print(ans)

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


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

k = int(input())
ans = {2: -1, 3: 1, 5: -1, 7: 1}
if k in ans:
    print(ans[k])
if k % 7 == 0:
    k //= 7

p = make_divisors(k-1)
for i in p:
    if int('7' * i) % p == 0:
        print(i)
Problem p02598 (python)

Fixed submission:
def ceil(X, Y):  # 天井関数 ceil(X/Y) Y>1
    return (X + Y - 1) // Y


def binary(N):  # 二分探索 # N:探索要素数
    l, r = -1, N
    while r - l > 1:
        if (l + r) // 2 == 0:
            return 1
        cnt = sum(ceil(ai, (l + r) // 2) - 1 for ai in a)
        if cnt <= k:  # 条件式を代入
            r = (l + r) // 2
        else:
            l = (l + r) // 2
    return r


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

print(binary(max(a)))

Buggy submission (verdict: Runtime Error):
def ceil(X, Y):  # 天井関数 ceil(X/Y) Y>1
    return (X + Y - 1) // Y


def binary(N):  # 二分探索 # N:探索要素数
    l, r = -1, N
    while r - l > 1:
        cnt = sum(ceil(ai, (l + r) // 2) - 1 for ai in a)
        if cnt <= k:  # 条件式を代入
            r = (l + r) // 2
        else:
            l = (l + r) // 2
    return l


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

print(binary(max(a)))

Buggy submission (verdict: Runtime Error):
def ceil(X, Y):  # 天井関数 ceil(X/Y) Y>1
    return (X + Y - 1) // Y


def binary(N):  # 二分探索 # N:探索要素数
    l, r = -1, N
    while r - l > 1:
        cnt = sum(ceil(ai, (l + r) // 2) - 1 for ai in a)
        if cnt <= k:  # 条件式を代入
            r = (l + r) // 2
        else:
            l = (l + r) // 2
    return r


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

print(binary(max(a)))
Problem p02659 (python)

Fixed submission:
a, b = map(int, input().replace('.', '').split())
print(a*b//100)

Buggy submission (verdict: Runtime Error):
a, b = map(str, input().split())
a, b = int(a), int(b*100)
print(a*b//100)
Problem p02689 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

near = [[0] for _ in range(n)]
for a, b in ab:
    near[a-1].append(h[b-1])
    near[b-1].append(h[a-1])

cnt = 0
for i in range(n):
    if h[i] > max(near[i]):
        cnt += 1
print(cnt)

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

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

h_max = [0 for _ in range(n)]
for a, b in ab:
    h_max[a-1] = max(h_max[a-1], h[b-1])
    h_max[b-1] = max(h_max[b-1], h[a-1])

cnt = 0
for i in range(n):
    if h[i] > h_max:
        cnt += 1
print(cnt)
Problem p02757 (python)

Fixed submission:
from collections import Counter

n, p = map(int, input().split())
s = input()

ans = 0

if p in {2, 5}:
    lst = set(i for i in range(0, 10, p))
    for i, num in enumerate(s):
        if int(num) in lst:
            ans += i + 1
else:
    num = [int(s[-1]) % p]
    for i in range(1, len(s)):
        tmp = num[-1] + pow(10, i, p) * int(s[-i - 1])
        num.append(tmp % p)
    mod = [1] + [0] * (p - 1)
    for i in num:
        ans += mod[i]
        mod[i] += 1
print(ans)

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

n, p = map(int, input().split())
s = list(map(int, list(input())))

ans = 0
if p in {2, 5}:
    for i, num in enumerate(s):
        if num % p == 0:
            ans += i + 1
else:
    modp = [0]
    for num in s[::-1]:
        tmp = modp[-1] + pow(10, i, p) * num
        modp.append(tmp % p)
    cnt = [0] * p
    for i in modp:
        ans += cnt[i]
        cnt[i] += 1
print(ans)

if p == 3:
    print('hoge')
Problem p02773 (python)

Fixed submission:
n = int(input())
s = [str(input()) for _ in range(n)]
s.append('zzzzzzzzzzz')
s.sort()

l_cnt = []
c_max = 1
cnt = 1
bfo = 'xxxxxxxxxxx'

for i in s:
    if i == bfo:
        cnt += 1
        c_max = max(c_max, cnt)
    else:
        l_cnt.append([bfo, cnt])
        bfo = i
        cnt = 1

for j in range(len(l_cnt)):
    if j == 0:
        continue
    else:
        if c_max == l_cnt[j][1]:
            print(l_cnt[j][0])

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

n = int(input())
s = [input() for _ in range(n)]

scnt = Counter(s)
cnt = max(s.values())
ans = sorted(k for k in scnt if scnt[v] == cnt)
print(*ans, sep='\n')

if n == 4:
    print(n)
Problem p02831 (python)

Fixed submission:
import fractions

x, y = map(int, input().split())
print((x * y) // fractions.gcd(x, y))

Buggy submission (verdict: Runtime Error):
import math

x, y = map(int, input().split())
print((x * y) // math.gcd(x, y))
Problem p02834 (python)

Fixed submission:
from collections import deque


def nearlist(N, LIST):  # 隣接リスト
    NEAR = [set() for _ in range(N)]
    for a, b in LIST:
        NEAR[a - 1].add(b - 1)
        NEAR[b - 1].add(a - 1)
    return NEAR


def bfs(NEAR, S, N):  # 幅優先探索  # キュー
    dist = [-1 for _ in range(N)]  # 前処理
    dist[S] = 0
    que, frag = deque([S]), set([S])

    while len(que) > 0:
        q = que.popleft()
        for i in NEAR[q]:  # 移動先の候補
            if i in frag:  # 処理済みか否か
                continue
            dist[i] = dist[q] + 1
            que.append(i), frag.add(i)
    return dist


n, u, v = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]

near = nearlist(n, ab)
tkdist, akdist = bfs(near, u - 1, n), bfs(near, v - 1, n)

node = [i for i in range(n) if tkdist[i] <= akdist[i]]
ans = max((akdist[i], i) for i in node)
print(ans[0] - 1)

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


def nearlist(N, LIST):  # 隣接リスト
    NEAR = [set() for _ in range(N)]
    for a, b in LIST:
        NEAR[a - 1].add(b - 1)
        NEAR[b - 1].add(a - 1)
    return NEAR


def bfs(NEAR, S, N):  # 幅優先探索  # キュー
    dist = [-1 for _ in range(N)]  # 前処理
    dist[S] = 0
    que, frag = deque([S]), set([S])

    while len(que) > 0:
        q = que.popleft()
        for i in NEAR[q]:  # 移動先の候補
            if i in frag:  # 処理済みか否か
                continue
            dist[i] = dist[q] + 1
            que.append(i), frag.add(i)
    return dist


n, u, v = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]

near = nearlist(n, ab)
tkdist, akdist = bfs(near, u - 1, n), bfs(near, v - 1, n)

node = [i for i in range(n) if tkdist[i] <= akdist[i]]
ans = max(akdist[i] for i in node)
print(ans[0] - 1)
Problem p02880 (python)

Fixed submission:
import sys

n = int(input())

for i in range(1,10):
    if (n % i == 0) and (n//i < 10):
        print('Yes')
        sys.exit()
print('No')

Buggy submission (verdict: Runtime Error):
import sys

n = int(input())

for i in range(n):
    if (n % i == 0) and (n//i < 10):
        print('Yes')
        sys.exit()
print('No')
Problem p02881 (python)

Fixed submission:
n = int(input())

cnt = 0
for i in range(1, int(n ** 0.5)+1):
    if n % i == 0:
        cnt = max(cnt, i)

print(cnt + n//cnt - 2)

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

cnt = 0
for i in range(1, int(n ** 0.5)):
    if n % i == 0:
        cnt = max(cnt, i)

print(cnt + n//cnt - 2)
Problem p02897 (python)

Fixed submission:
n = int(input())
if n % 2 == 0: print(1 / 2)
else: print((n+1)/2/n)

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

Fixed submission:
a=int(input())
s=input()
if a<3200:
	print("red")
else:
	print(s)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
ab.sort()
cnt = [0]*n

for i in px:
    cnt[i[0] - 1] += i[1]
for j in ab:
    cnt[j[1]-1] += cnt[j[0]-1]

print(*cnt)
Problem p02935 (python)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
while len(a)>1:
	a.sort()
	x=a.pop(0)
	y=a.pop(0)
	a.append((x+y)/2)
print(a[0])

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
a.sort()
for i in(1,N):
	a[0]=(a[0]+a[i])/2
print(a[0])

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
for i in range(0,N):
	a.sort()
	x,y=map(int,a.pop())
	a.append((x+y)/2)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
while len(a)>=2:
	a.sort()
	x,y=map(int,a.pop())
	a.append((x+y)/2)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
while len(a)>=2:
	a.sort()
	x,y=map(int,list.pop())
	a.append((x+y)/2)
Problem p03045 (python)

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

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):  # 根のリスト
        return [i for i, x in enumerate(self.parents) if x < 0]


n, m = map(int, input().split())
xyz = sorted([list(map(int, input().split())) for _ in range(m)])

uf = Unionfind(n)
for x, y, z in xyz:
    uf.union(x - 1, y - 1)
print(len(uf.roots()))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
xyz = sorted([map(int, input().split()) for _ in range(m)])

ans, find = 0, set([])
for x, y, z in xyz:
    if not (x or y) in find:
        ans += 1
    find.add(x)
    find.add(y)
print(ans + (n - len(find)))
Problem p03108 (python)

Fixed submission:
class Unionfind():  # Unionfind
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # グループのサイズ
        return - self.parents[self.find(x)]

    def same(self, x, y):  # 同じグループか否か
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uf = Unionfind(n)
ans, cnt = [], n * (n - 1) // 2
for a, b in ab[::-1]:
    ans.append(max(cnt, 0))
    if not uf.same(a - 1, b - 1):
        cnt -= uf.size(a - 1) * uf.size(b - 1)
        uf.union(a - 1, b - 1)
print(*ans[::-1], sep='\n')

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

    def find(self, x):  # グループの根
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # グループの併合
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # グループのサイズ
        return - self.parents[self.find(x)]


n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

uf = Unionfind(n)
ans, cnt = [], n * (n - 1) // 2
for a, b in ab[::-1]:
    a -= 1, b -= 1
    ans.append(max(cnt, 0))
    if uf.find(a) != uf.find(b):
        cnt -= uf.size(a) * uf.size(b)
        uf.union(a, b)
print(*ans[::-1], sep='\n')
Problem p02915 (python)

Fixed submission:
N = int(input())
a = N**3
print(a)

Buggy submission (verdict: Runtime Error):
N = int(intput())
print(N ** 3)

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

print(N ** 3)
Problem p02933 (python)

Fixed submission:
N = int(input())
s = input()
  
if N < 3200:
  print('red')
else:
  print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = input()
  
if s < 3200:
  print('red')
else:
  print(s)
Problem p03186 (python)

Fixed submission:
A, B, C = map(int, input().split())

print(min(A+B+1, C) + B)

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

print(min((A+B, C) + min(B, C)))
Problem p03221 (python)

Fixed submission:
import numpy as np

N, M = map(int, input().split())
P = []
Y = []
for _ in range(M):
    p, y = map(int, input().split())
    P.append(p)
    Y.append(y)
P = np.array(P)
Y = np.array(Y)
PY = np.c_[P, Y]
sort_ind = np.argsort(Y)

PY_sort = PY[sort_ind]
count = [0] * (int(1e+5) + 1)
id_list = []
for p, y in PY_sort:
    count[p] += 1
    id_list.append(str(p).zfill(6) + str(count[p]).zfill(6))

id_list = np.array(id_list)
id_list = id_list[np.argsort(sort_ind)]
for city_id in id_list:
    print(city_id)

Buggy submission (verdict: Runtime Error):
import bisect
N, M = map(int, input().split())
P, Y = [], []
pref = [[] for _ in range(N+1)] # non-0-indexed
for m in range(M):
    p,y = map(int, input().split())
    P.append(p)
    Y.append(y)
for i in len(pref):
	pref[i].sort()
    
for p,y in zip(P,Y):
    ans = "{:0>6}".format(p)
    i = bisect.bisect(pref[p], y)
    ans += "{:0>6}".format(i)
    print(ans)

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

N, M = map(int, input().split())
P = [None] * (N+1)
Y = [None] * (N+1)
for i in range(M):
    p, y = map(int, input().split())
    P[i] = p
    Y[i] = y
P = np.array(P)
Y = np.array(Y)
PY = np.c_[P, Y]
sort_ind = np.argsort(Y)
PY_sort = PY[sort_ind]
count = [0] * (N+1)
id_list = [None] * (N+1)
for i, py in enumerate(PY_sort):
    count[py[0]] += 1
    id_list[i] = (str(py[0]).zfill(6) + str(count[py[0]]).zfill(6))
id_list = np.array(id_list)
id_list = id_list[np.argsort(sort_ind)]
for city_id in id_list:
    print(city_id)
Problem p03986 (python)

Fixed submission:
s = list(input())
l = []
for i in range(len(s)):
    if s[i] == 'S':
        l.append('S')
    elif not l:
        l.append('T')
    elif l[-1] == 'T':
        l.append('T')
    else:
        l.pop()
print(len(l))

Buggy submission (verdict: Runtime Error):
s = list(input())
l = []
for i in range(len(s)):
    if s[i] == 'S':
        l.append('S')
    elif l[-1] == 'T' or not l:
        l.append('T')
    else:
        l.pop()
print(len(l))
Problem p02793 (python)

Fixed submission:
from fractions import gcd  # python<=3.4

MOD=1000000007

def ADD(x, y):
  return (x + y) % MOD

def SUB(x, y):
  return (x - y + MOD) % MOD

def MUL(x, y):
  return x * y % MOD

def POW(x, e):
  v = 1
  while e:
    if e & 1:
      v = MUL(v, x)
    x = MUL(x, x)
    e >>= 1
  return v

def INV(x):
  return POW(x, MOD-2)

def DIV(x, y):
  return MUL(x, INV(y))


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

el = 1
for ai in a:
  g = gcd(el,ai)
  el = el // g * ai

el %= MOD

sum = 0
for ai in a:
  sum += DIV(el, ai)

sum %= MOD
print(sum)

Buggy submission (verdict: Runtime Error):
from fractions import gcd  # python<=3.4

MOD=1000000007

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

el = 1
for ai in a:
  g = gcd(a,b)
  el = el // g * b

sum = 0
for ai in a:
    sum = (sum + el // ai) % MOD

print(sum)
Problem p02546 (python)

Fixed submission:
S = input()
if S[-1] == 's':
    ans = S+'es'
else:
    ans = S+'s'
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
if S[-1] == 's':
  ans += 'es'
else:
  ans += 's'
print(ans)
Problem p02597 (python)

Fixed submission:
N = int(input())
c = input()

num_R = c.count('R')

print(c[:num_R].count('W'))

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

first_R = c.index('R')
num_R = c.count('R')

print(first_R+c[first_R:first_R+num_R].count('W'))
Problem p02754 (python)

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

if A == 0:
    print(0)
    exit()

s = N // (A+B)
p = N%(A+B)
if p//A == 0:
    ans = s*A+p
else:
    ans = s*A+A
print(ans)

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

if A == 0:
    print(0)
    exit()

s = N // (A+B)
p = (N%(A+B))
if p//A == 0:
    ans = s*A+p
elif p//A == 1:
    ans = s*A+A
print(ans)
Problem p02580 (python)

Fixed submission:
h, w, m = map(int, input().split())
HW = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]

sum_h = [[0,0] for _ in range(h)] # [sum, index]
sum_w = [[0,0] for _ in range(w)]
for i in range(m):
    h,w = HW[i]
    sum_h[h][0] += 1
    sum_w[w][0] += 1
    sum_h[h][1] = h
    sum_w[w][1] = w

h_num_ix = {}
for num,ix in sum_h:
    if not num in h_num_ix:
        h_num_ix[num] = set()
    h_num_ix[num].add(ix)

w_num_ix = {}
for num,ix in sum_w:
    if not num in w_num_ix:
        w_num_ix[num] = set()
    w_num_ix[num].add(ix)

max_h_num = max(h_num_ix)
max_w_num = max(w_num_ix)

# print(sorted(HW))
# print('---')
# print(h_num_ix)
# print(w_num_ix)
# print(max_h_num)
# print(max_w_num)
# print('====')

SHW = set()
for h,w in HW:
    SHW.add((h,w))
# print(SHW)

max_num = max_h_num + max_w_num - 1
for h_ix in h_num_ix[max_h_num]:
    for w_ix in w_num_ix[max_w_num]:
        num = max_h_num + max_w_num
        # if [h_ix, w_ix] in HW: continue
        if (h_ix, w_ix) in SHW: continue
        max_num += 1
        print(max_num)
        exit()
print(max_num)

Buggy submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
HW = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]

# print(h,w,m)
HW.sort()
# print(*HW,sep='\n')
# print('---')

sum_h = [[0,0] for _ in range(h)] # [sum, index]
sum_w = [[0,0] for _ in range(w)]


for i in range(m):
    # print(h,w)
    h,w = HW[i]
    sum_h[h][0] += 1
    sum_w[w][0] += 1
    sum_h[h][1] = h
    sum_w[w][1] = w

# # print('---')
# # print(sum_h)
# # print(sum_w)
# # print('---')
sum_h.sort(reverse=True)
sum_w.sort(reverse=True)
# print(sum_h)
# print(sum_w)
# print('---')

from bisect import *

# print(HW)

max_bombs = 0
if sum_h[0][0] > sum_w[0][0]:
    h_bombs, h_index = sum_h[0]
    for w_bombs, w_index in sum_w:
        bombs = h_bombs + w_bombs
        ix = bisect_left(HW, [h_index, w_index])
        # print('ix {}'.format(ix))
        # if [h_index, w_index] in HW:
        if [h_index, w_index] ==  HW[ix]:
            bombs -= 1
        if max_bombs < bombs:
            max_bombs = bombs

else:
    for h_bombs, h_index in sum_h:
        bombs = sum_w[0][0] + h_bombs
        if [h_index, sum_w[0][1]] in HW:
            bombs -= 1
        if max_bombs < bombs:
            max_bombs = bombs

print(max_bombs)