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

Fixed submission:
n,m,k = map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
if sum(al)+sum(bl)<=k:
  print(n+m)
  exit()
ans = 0
used = 0
indexa = indexb = -1
for i in range(n):
  if used+al[i] <= k:
    used += al[i]
    indexa=i
    ans += 1
  else:
    break
for i in range(m):
  if used+bl[i] <= k:
    used += bl[i]
    indexb = i
    ans+=1
  else:
    break

tmp = ans
for i in range(indexa,-1,-1):
  used -= al[i]
  tmp -= 1
  while indexb<m-1 and bl[indexb+1]+used <=k:
    used += bl[indexb+1]
    indexb += 1
    tmp += 1
  ans = max(tmp,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
if sum(al)+sum(bl)<=k:
  print(n+m)
  exit()
ans = 0
used = 0
indexa = indexb = -1
for i in range(n):
  if used+al[i] <= k:
    used += al[i]
    indexa=i
  else:
    ans += i
    break
for i in range(m):
  if used+bl[i] <= k:
    used += bl[i]
    indexb = i
  else:
    ans += i
    break

tmp = ans
for i in range(indexa,-1,-1):
  used -= al[i]
  tmp -= 1
  while bl[indexb+1]+used <=k:
    used += bl[indexb+1]
    indexb += 1
    tmp += 1
  ans = max(tmp,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
if sum(al)+sum(bl)<=k:
  print(n+m)
  exit()
ans = 0
used = 0
indexa = indexb = 0
for i in range(n):
  if used+al[i] <= k:
    used += al[i]
  else:
    indexa = i
    ans += i
    break
for i in range(m):
  if used+bl[i] <= k:
    used += bl[i]
  else:
    indexb = i
    ans += i
    break

tmp = ans
for i in range(indexa-1,-1,-1):
  used -= al[i]
  tmp -= 1
  while bl[indexb]+used <=k:
    used += bl[indexb]
    indexb += 1
    tmp += 1
  ans = max(tmp,ans)
print(ans)
Problem p02629 (python)

Fixed submission:
n = int(input())-1
x = 26
d = 1
while n >= x:
  n -= x
  d += 1
  x *= 26
  
ans = ""
al = list("abcdefghijklmnopqrstuvwxyz")
tmp = pow(26,d)
for i in range(d-1,-1,-1):
  tmp //= 26 
  ans += al[n//tmp]
  n %= tmp
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())-1
x = 26
d = 1
while n > x:
  n -= x
  d += 1
  x *= 26
  
ans = ""
al = list("abcdefghijklmnopqrstuvwxyz")
tmp = pow(26,d)
for i in range(d-1,-1,-1):
  tmp //= 26 
  ans += al[n//tmp]
  n %= tmp
print(ans)
Problem p02659 (python)

Fixed submission:
a,b = input().split()
a = int(a)
b,bb = b.split(".")
b = int(b)*100+int(bb)
print((a*b)//100)

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

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

mod = 998244353
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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

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

if k==n-1:
  print(pow(m,n,mod))
  exit()

ans = 0
a= m*pow(m-1,n-1-k-1,mod)

for i in range(k,-1,-1):
  a =a*(m-1)%mod
  
  ans += a*cmb(n-1,i,mod)
  ans %= mod
  
print(ans)

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

mod = 998244353
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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

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

ans = 0
a= m*pow(m-1,n-1-k-1,mod)

for i in range(k,-1,-1):
  a =a*(m-1)%mod
  
  ans += a*cmb(n-1,i,mod)
  ans %= mod
  
print(ans)
Problem p02689 (python)

Fixed submission:
n,m = map(int,input().split())
h= list(map(int,input().split()))
ans = [1]*n

for i in range(m):
  a,b = map(int,input().split())
  a-=1
  b-=1
  if h[a]>=h[b]:
    ans[b]=0
  if h[a]<=h[b]:
    ans[a]=0
print(sum(ans))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
h= list(map(int,input().split()))
ans = [1]*n

for i in range(m):
  a,b = map(int,input().split())
  if h[a]>=h[b]:
    ans[b-1]=0
  if h[a]<=h[b]:
    ans[a-1]=0
print(sum(ans))
Problem p02792 (python)

Fixed submission:
n= int(input())

mat = [ [0]*10 for i in range(10)]

for i in range(1,n+1):
  a,b = int(str(i)[0]), i%10
  mat[a][b] += 1

ans = 0
for i in range(1,10):
  for j in range(1,10):
    ans += mat[i][j]*mat[j][i]

print(ans)

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

mat = [[0]*(10)]*(10)

for i in range(1,n+1):
  a,b = str(i)[0],str(i)[-1]:
  mat[a][b] += 1

ans = 0
for i in range(1,10):
  for j in range(1,10):
    ans += mat[i][j]*mat[j][i]
print(ans)
Problem p02833 (python)

Fixed submission:
n = int(input())

if n %2 ==1:
  print(0)
else:
  mod = 10
  ans = 0
  x = 0
  while True:
    x = n//mod
    if x==0: break
    ans+=x
    mod *= 5
  print(ans)

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

if n %2 ==1:
  print(0)
else:
  mod = 10
  ans = 0
  x = 0
  while(x>0):
    x = n//mod
    ans+=x
    mod *= 5
print(ans)

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

  if n %2 ==1:
    print(0)
  else:
    mod = 10
    ans = n//mod
    x = n//mod
    while(x>0):
      mod *= 5
      x = n//mod
      ans+=x
print(ans)
except Exception as e:
  print(e)

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

if n %2 ==1:
  print(0)
else:
  mod = 10
  ans = n//mod
  x = n//mod
  loop = 0
  while(x>0 and loop<10**7):
    loop += 1
    mod *= 5
    x = n//mod
    ans+=x
print(ans)

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

if n %2 ==1:
  print(0)
else:
  mod = 10
  ans = n//mod
  x = n//mod
  while(x>0):
    mod *= 5
    x = n//mod
    ans+=x
print(ans)

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

if n %2 ==1:
  print(0)
else:
  mod = 10
  ans = x = n//mod
  
  while(x>=0):
    mod *= 5
    x = n//mod
    ans+=x
print(ans)

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

if n %2 ==1:
  print(0)
else:
  mod = 10
  ans = x = n//mod
  
  while(x>0):
    mod *= 5
    x = n//mod
    ans+=x
print(ans)
Problem p02891 (python)

Fixed submission:
t = input()
s = list(t)
k = int(input())

ans = 0

s = s+s
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    s[i] = "0"
    if i>=len(s)//2:
      ans += k-1
    else:
      ans += 1
      
if len(set(list(t))) == 1 and len(t)%2 == 1:
  ans = len(t) * (k//2) + (k%2==1)*(len(t)//2)
print(ans)

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

ans = 0

s = s+s
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    s[i] = "0"
    if i>=len(s)//2:
      ans += k-1
    else:
      ans += 1
      
if len(set(list(t))) == 1 and len(t)%2 == 1:
  ans = len(t) * (k//2) + (k%2==1)*(t//2)
print(ans)

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

ans = 0

s = s+s
for i in range(1,len(s)):
  if s[i-1] == s[i]:
    s[i] = "0"
    if i>=len(s)//2:
      ans += k-1
    else:
      ans += 1
      
if len(set(list(t))) == 1 and len(t)%2 == 1:
  ans = len(t) * (k//2) + (k%2==1)*(k//2)
  ans = 1/0
print(ans)
Problem p02897 (python)

Fixed submission:
n = int(input())

print(0.5 if n%2==0 else (n//2+1)/n)

Buggy submission (verdict: Runtime Error):
def main():
  import fractions
  import math

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

  if a>b:
    a,b = b,a
  
  d = [1]
  num = 2

  while num <= min(a,b):
    if a%num == 0 and b%num == 0:
      d.append(num)
      while a%num == 0 and a>1:
        a = a//num
      while b%num == 0 and b>1:
        b = b//num
    num+=1
  
  print(len(d))

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

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

Buggy submission (verdict: Runtime Error):
import numpy as np
n,q= map(int,input().split())

edges = {i+1:[] for i in range(n+1)}
for i in range(n-1):
  a,b = map(int,input().split())
  edges[a].append(b)

ans = np.zeros(n)
dp = {i:np.zeros(n) for i in range(1,n+1)}
for i in range(1,n+1):
  dp[i][i-1] = 1
for i in range(n,0,-1):
  for j in edges[i]:
    dp[i] += dp[j]

queries = [0]*(n+1)
for _ in range(q):
  p,x = map(int,input().split())
  queries[p] += x
for i in range(1,n+1):
  ans += queries[i]*dp[i]
    
st = ""
for i in range(n):
  if i != 0:
    st+=" "
  st+= str(int(ans[i]))
print(st)

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

if n>= 3200:
  print(red)
else:
  print(input())
Problem p02948 (python)

Fixed submission:
import heapq

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

ls = [list(map(int,input().split())) for i in range(n)]

ls = sorted(ls,key=lambda x:(x[0],-x[1]))

ans = 0
a = []
j = 0
for i in range(m-1,-1,-1):
  while j<len(ls) and ls[j][0] == m-i:
    heapq.heappush(a,ls[j][1]*(-1))
    j += 1
  
  if a:
    ans += -1*heapq.heappop(a)

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq

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

ls = [list(map(int,input().split())) for i in range(n)]

ls = sorted(ls,key=lambda x:(x[0],-x[1]))

ans = 0
a = []
j = 0
for i in range(m-1,-1,-1):
  while j<len(ls) and ls[j][0] == m-i:
    heapq.heappush(a,ls[j][1]*(-1))
    j += 1
  g = -1*heapq.heappop(a)
  ans += g

print(ans)
Problem p02951 (python)

Fixed submission:
a,b,c = map(int,input().split())

print(max(0,c-a+b))

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

print(max(0,c-a+b))
Problem p02984 (python)

Fixed submission:
n = int(input())

lsA = list(map(int,input().split()))
tot = sum(lsA)

an = tot
for i in range(0,n-2,2):
  an -= 2*lsA[i]

ans = [2*lsA[i] for i in range(n)]
ans[n-1] = an
for i in range(n-2,-1,-1):
  ans[i] -= ans[i+1]

print(" ".join(list(map(str,ans))))

Buggy submission (verdict: Runtime Error):
mod = 2019
l,r = map(int,input().split())

if l==0 or r//mod - (l-1)//mod >= 1:
  print(0)
else:
  print(l*(l+1)%mod)
Problem p03017 (python)

Fixed submission:
N,A,B,C,D = map(lambda x: int(x)-1,input().split())
S = input()

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "#" and S[i+1] is "#": return True
  return False

if obs(B,D) or obs(A,C):
  print("No")
elif C > D:
  b = False
  for i in range(B-1,min(D,N-2)):
    if S[i] is "." and S[i+1] is "." and S[i+2] is ".":
      b = True
      break
  if b:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

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

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "#" and S[i+1] is "#": return True
  return False

if obs(B,D) or obs(A,C):
  print("No")
elif C > D:
  b = False
  for i in range(B-1,max(D,N-2)):
    if S[i] is "." and S[i+1] is "." and S[i+2] is ".":
      b = True
      break
  if b:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

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

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "#" and S[i+1] is "#": return True
  return False

if obs(B,D) or obs(A,C):
  print("No")
elif C > D:
  b = False
  for i in range(B-1,D):
    if S[i] is "." and S[i+1] is "." and S[i+2] is ".":
      b = True
      break
  if b:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")
Problem p03045 (python)

Fixed submission:
class 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)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
      
def main():
  n,m = map(int,input().split())
  u = UnionFind(n)
  
  for _ in range(m):
    x,y,_ = map(int,input().split())
    u.union(x-1,y-1)
  print(u.group_count())
  
if __name__ == "__main__":
  main()

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

N,M = map(int,input().split())

xy = {i:[] for i in range(1,N+1)}
visited = {i:False for i in range(1,N+1)}

for _ in range(M):
  x,y,z = map(int,input().split())
  xy[x].append(y)
  xy[y].append(x)

def dfs(p):
  visited[p] = True
  for q in xy[p]:
    if visited[q]:
      pass
    else:
      dfs(q)
      
count = 0
for i in range(1,N+1):
  if visited[i]:
    continue
  else:
    count += 1
    dfs(i)
print(count)
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = [int(x) for x in input().split()]
found = False
for i in range(a, b + 1):
    if i % k == 0:
        found = True
if found:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
a, b = [int(x) for x in input().split()]
k = int(input())
found = False
for i in range(a, b + 1):
    if i % k == 0:
        found = True
if found: 
    print("YES")
else:
    print("NO")
Problem p02572 (python)

Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]

mod = 10**9 + 7

print(((sum(A)**2 - sum([i**2 for i in A]))//2) % mod)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]

import numpy as np

mod = 10**9 + 7

mesh = np.array(np.meshgrid(A, A), dtype=np.int64)
comb = mesh.T.reshape(-1, 2)

t_comb = []
for c in comb:
    if c[0] == c[1]:
        continue
    else:
        t_comb.append(sorted(c))

t_comb = np.unique(t_comb, axis=0)

summa = 0
for c in t_comb:
    summa += c[0] * c[1]

print(summa % mod)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]

import numpy as np

mod = 10**9 + 7

def pairwise_combs_mask(a):
    a = np.array(a, dtype=np.int64)
    n = len(a)
    L = n*(n-1) // 2
    out = np.empty((L,2), dtype=a.dtype)
    m = ~np.tri(len(a), dtype=bool)
    out[:,0] = np.broadcast_to(a[:,None],(n,n))[m]
    out[:,1] = np.broadcast_to(a,(n,n))[m]
    return out

comb = pairwise_combs_mask(A)

summa = 0
for c in comb:
    summa += c[0] * c[1]

print(int(summa % mod))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]

import numpy as np

mod = 10**9 + 7

def pairwise_combs_mask(a):
    a = np.array(a, dtype=np.float64)
    n = len(a)
    L = n*(n-1)//2
    out = np.empty((L,2), dtype=a.dtype)
    m = ~np.tri(len(a),dtype=bool)
    out[:,0] = np.broadcast_to(a[:,None],(n,n))[m]
    out[:,1] = np.broadcast_to(a,(n,n))[m]
    return out

comb = pairwise_combs_mask(A)

summa = 0
for c in comb:
    summa += c[0] * c[1]

print(int(summa % mod))
Problem p02754 (python)

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

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

quotient = N // (A + B) * A
remainder = N % (A + B)

quotient += min((remainder, A))

print(quotient)

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

mojiretsu = ''
while len(mojiretsu) < N:
    mojiretsu += 'b' * A
    mojiretsu += 'r' * B

print(mojiretsu[:N].count('b'))
Problem p03011 (python)

Fixed submission:
L = [int(i) for i in input().split()]

min_root = []
for i in L:
    for j in L:
        if i != j:
            min_root.append(i+j)
        else:
            continue
            
if len(min_root) > 0:
    print(min(min_root))
else:
    print(L[0]+L[1])

Buggy submission (verdict: Runtime Error):
L = [int(i) for i in input().split()]

min_root = []
for i in L:
    for j in L:
        if i != j:
            min_root.append(i+j)
        else:
            continue

print(min(min_root))

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

min_root = []
for i in L:
    for j in L:
        if i != j:
            min_root.append(i+j)
        else:
            continue

print(min(min_root))
Problem p02659 (python)

Fixed submission:
from sys import stdin
import sys

a, b = [x for x in stdin.readline().rstrip().split()]
a = int(a)
b = int(b.replace('.',''))

print(a * b  // 100)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import sys

a,b = [int(x) for x in stdin.readline().rstrip().split()]
print(a*(b*100)/100)
Problem p02773 (python)

Fixed submission:
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())

d = {}
for i in range(n):
    s = stdin.readline().rstrip()

    if s in d:
        d[s] += 1
    else:
        d[s] = 1

d = sorted(d.items(), key=lambda x:x[1], reverse=True)

m = d[0][1]
a = []
i = 0
for i in range(len(d)):
    if d[i][1] == m:
        a.append(d[i][0])
    else:
        break

a.sort()

for aa in a:
    print(aa)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())

d = {}

for i in range(n):
    s = stdin.readline().rstrip()

    if s in d:
        d[s] += 1
    else:
        d[s] = 1

d = sorted(d.items(), key=lambda x:x[1], reverse=True)

m = d[0][1]
a = []
for i in range(n):
    if d[i][1] == m:
        a.append(d[i][0])
    else:
        break

a.sort()

for aa in a:
    print(aa)
Problem p02598 (python)

Fixed submission:
import math

def check(d):
    cut_num = 0
    for i in leng:
        cut_num += math.ceil(i / d) - 1
    if cut_num <= K:
        return True
    return False


N, K = map(int, input().split())
leng = list(map(int, input().split()))

d_min = 0
d_max = max(leng)
d = math.ceil(d_max / 2)

while d_max - d_min > 1:
    if check(d):
        d_max = d
        d = math.ceil((d_max + d_min) / 2)
    else:
        d_min = d
        d = int((d_max + d_min) / 2)
    # print(d, d_max, d_min)

print(d_max)

Buggy submission (verdict: Runtime Error):
import math

def check(d):
    cut_num = 0
    for i in leng:
        cut_num += math.ceil(i / d) - 1
    if cut_num <= K:
        return True
    return False


N, K = map(int, input().split())
leng = list(map(int, input().split()))

d_min = 0
d_max = max(leng)
d = d_max / 2

while d_max - d_min >= 1:
    if check(d):
        d_max = d
    else:
        d_min = d
    d = (d_max + d_min) / 2
    # print(d, d_max, d_min)

if check(math.ceil(d_min)):
    print(math.ceil(d_min))
else:
    print(math.ceil(d_min)+1)

Buggy submission (verdict: Runtime Error):
import math

def check(d):
    cut_num = 0
    for i in leng:
        cut_num += math.ceil(i / d) - 1
    if cut_num <= K:
        return True
    return False


N, K = map(int, input().split())
leng = list(map(int, input().split()))
d = max(leng)

d_min = 0
d_max = d

while d_max - d_min >= 1:
    if check(d):
        d_max = d
    else:
        d_min = d
    d = (d_max + d_min) / 2
    # print(d, d_max, d_min)

if check(math.ceil(d_min)):
    print(math.ceil(d_min))
else:
    print(math.ceil(d_min)+1)
Problem p02624 (python)

Fixed submission:
# import time
N = int(input())
ssum = 0
# start = time.time()
for k in range(1, N + 1):
    X = int(N / k)
    ssum += k * X * (X + 1) / 2
print(int(ssum))
# elapsed_time = time.time() - start
# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")

Buggy submission (verdict: Runtime Error):
N = int(input())
ssum = 0
start = time.time()
for k in range(1, N + 1):
    X = int(N / k)
    ssum += k * X * (X + 1) / 2
print(int(ssum))
Problem p02580 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    H, W, M = map(int, input().split())
    bombs = []
    hs = [0] * H
    ws = [0] * W
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append(tuple([h-1, w-1]))
        hs[h-1] += 1
        ws[w-1] += 1
    maxh = max(hs)
    maxw = max(ws)
    ans = maxh + maxw

    maxhindex = [i for i, x in enumerate(hs) if x == maxh]
    maxwindex = [i for i, x in enumerate(ws) if x == maxw]

    bombs = set(bombs)
    for i in maxhindex:
        for j in maxwindex:
            if (i, j) not in bombs:
                print(ans)
                exit()
    print(ans-1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    H, W, M = map(int, input().split())
    mm = []
    l = np.zeros((H, W))
    for i in range(M):
        a, b = map(int, input().split())
        mm.append([a, b])
        l[a-1][b-1] = 1
    row_max = 0
    row_num = 0
    col_max = 0
    col_num = 0

    r = np.count_nonzero(l == 1, axis=1)
    row_max = max(r)
    row_num = np.argmax(r)

    c = np.count_nonzero(l == 1, axis=0)
    col_max = max(c)
    col_num = np.argmax(c)

    a = np.count_nonzero(c == col_max)
    if [row_num+1, col_num+1] in mm:
        print(row_max + col_max - 1)
    else:
        print(row_max + col_max)
        
if __name__ == '__main__':
    main()
Problem p02695 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

import itertools

def main():
  N, M, Q = map(int, input().split())
  all_num = [i for i in range(1, M+1)]
  q_kumi = []
  for i in range(Q):
    q_kumi.append(list(map(int, input().split())))

  ans = 0
  for com in list(itertools.combinations_with_replacement(all_num, N)):
    tmp_ans = 0
    if com != tuple(sorted(com)):
      continue
    for q in q_kumi:
      if com[q[1]-1] - com[q[0]-1] == q[2]:
        tmp_ans += q[3]
    ans = max(ans, tmp_ans)
  print(ans)

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
                                                                               │➜  typical
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

import itertools

def main():
  N, M, Q = map(int, input().split())
  all_num = [i for i in range(1, M+1)]
  q_kumi = []
  for i in range(Q):
    q_kumi.append(list(map(int, input().split())))

  ans = 0
  for com in list(itertools.combinations_with_replacement(all_num, N)):
    tmp_ans = 0
    if com != tuple(sorted(com)):
      continue
    for q in q_kumi:
      if com[q[1]-1] - com[q[0]-1] == q[2]:
        tmp_ans += q[3]
    ans = max(ans, tmp_ans)
  print(ans)

if __name__ == '__main__':
  main()
Problem p02627 (python)

Fixed submission:
α = str(input())

if α == α.upper():
    print("A")
else:
    print("a")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(str,input().split()))
Q = int(input())
b = []
c = []
for i in range(Q):
    B,C = map(str,input().split())
    b.append(B)
    c.append(C)

for i in range(Q):
    if b[i] in A:
        A = [s.replace(b[i],c[i]) for s in A]
    print(sum(int(i) for i in A))
Problem p02595 (python)

Fixed submission:
n,d=map(int,input().split())
cnt=0
for i in range(n):
  x,y =map(int,input().split())
  if x**2+y**2 <= d**2:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,d=map(int,input())
cnt=0
for i in range(n):
  x,y =map(int,input())
  if x**2+y**2 <= d**2:
    cnt+=1
print(cnt)