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

Fixed submission:
N, A, B = map(int, input().split())
d = N//(A+B)
p = N%(A+B)

S = d*A + min(p, A)
print(S)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
a = 'b'*A+'r'*B
count=int(N/len(a))+N//len(a)
S = a*count
print(S[:N].count('b'))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
a = 'b'*A+'r'*B
count=int(N/len(a))+N//len(a)
for i in range(0,count):
    S += a
print(S[:N].count('b'))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
r = 'r'*B
b = 'b'*A
while len(S) < N+5:
    S += b
    S += r
print(S[:N].count('b'))
Problem p02577 (python)

Fixed submission:
import math

#N = int(input())
N =list(input())
#print(N)
cnt = 0
for i in range(len(N)):
  cnt += int(N[i])
  #print(N)

if cnt%9 ==0:
	print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

cnt = 0
while(N>0):
  cnt += N%10
  N = int(N/10)
  #print(N)

if cnt%9 ==0:
	print('Yes')
else: print('No')
Problem p02578 (python)

Fixed submission:
import math

#N = int(input())
N =int(input())
A =list(map(int, input().split()))
cnt = 0
cur = A[0]
for i in range(1,N):
  if cur > A[i]:
    cnt += cur - A[i]
  else:
    cur = A[i]

print(cnt)

Buggy submission (verdict: Runtime Error):
import math

#N = int(input())
N =int(input())
A =list(map(int, input().split())
        
#print(N)
cnt = 0
cur = A[0]
for i in range(1,N):
  if cur > A[i]:
    cnt += cur - A[i]
  else:
    cur = A[i]

print(cnt)
Problem p02570 (python)

Fixed submission:
import math

# input d:距離（メートル） , t:待ち合わせまで何分 , s:速度（分速sメートル）
d, t, s = map(int, input().split())

output = "";

if d/s > t:
    output = "No"
else:
    output = "Yes"

print(output)

Buggy submission (verdict: Runtime Error):
import math

# input d:距離（メートル） , t:待ち合わせまで何分 , s:速度（分速sメートル）
d, t, s = map(int, input().split())

output = "";

if d/s >= s:
    if math.ceil(d/s) = s:
        output = "Yes"
    else:
        output = "No"
else:
    output = "Yes"

print(output)
Problem p02552 (python)

Fixed submission:
x = int(input())

if x == 1:
  print(0)
 
else:
  print(1)

Buggy submission (verdict: Runtime Error):
if x == 0:
  print(1)
  
else:
  print(0)
Problem p02594 (python)

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

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

Fixed submission:
n, m = map(int, input().split())
alist = set([int(input()) for _ in range(m)])

MOD = pow(10, 9) + 7

if n == 1:
  if 1 in alist:
    print(0)
  else:
    print(1)
else:
  memo = [0 for _ in range(n)]
  memo[0] = 0 if 1 in alist else 1
  is_reach = True
  if 1 in alist and 2 in alist:
    is_reach = False
    memo[0] = 0
  elif 1 in alist:
    memo[1] = 1
  else:
    memo[1] = 2

  for i in range(2, n):
    if i+1 in alist:
      memo[i] = 0
    elif i in alist and i-1 in alist:
      memo[i] = 0
      is_reach = False
      break
    elif i in alist:
      memo[i] = memo[i-2]
    elif i-1 in alist:
      memo[i] = memo[i-1]
    else:
      memo[i] = (memo[i-1] + memo[i-2]) % MOD

  if is_reach:
    print(memo[-1])
  else:
    print(0)

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

MOD = pow(10, 9) + 7

memo = [0 for _ in range(n)]
memo[0] = 0 if 1 in alist else 1
is_reach = True
if 1 in alist and 2 in alist:
  is_reach = False
  memo[0] = 0
elif 1 in alist:
  memo[1] = 1
else:
  memo[1] = 2

for i in range(2, n):
  if i+1 in alist:
    memo[i] = 0
  elif i in alist and i-1 in alist:
    memo[i] = 0
    is_reach = False
    break
  elif i in alist:
    memo[i] = memo[i-2]
  elif i-1 in alist:
    memo[i] = memo[i-1]
  else:
    memo[i] = (memo[i-1] + memo[i-2]) % MOD

if is_reach:
  print(memo[-1])
else:
  print(0)
Problem p03104 (python)

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

base = 2
ans = ''
if a == 0 and b == 0:
  print(0)
else:
  while base // 2 <= b:
    nb = (b // base) * (base // 2)
    na = (a // base) * (base // 2)
    if b % base != 0:
      nb += max(0, b % base - (base // 2) + 1)
    if a % base != 0:
      na += max(0, (a - 1) % base - (base // 2) + 1)
    if (nb - na) % 2 == 1:
      ans += '1'
    else:
      ans += '0'
    base *= 2
  print(int(ans[::-1], 2))

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

base = 2
ans = ''
while base // 2 <= b:
  nb = (b // base) * (base // 2)
  na = (a // base) * (base // 2)
  if b % base != 0:
    nb += max(0, b % base - (base // 2) + 1)
  if a % base != 0:
    na += max(0, (a - 1) % base - (base // 2) + 1)
  if (nb - na) % 2 == 1:
    ans += '1'
  else:
    ans += '0'
  base *= 2
print(int(ans[::-1], 2))
Problem p03209 (python)

Fixed submission:
N, X = map(int, input().split())
a, p = [1], [1]
for i in range(N):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)

def f(N, X):
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

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

b = 'P'
for _ in range(N):
  b = 'B'+b+'P'+b+'B'

print(b[:X].count('P'))
Problem p03326 (python)

Fixed submission:
n, m = map(int, input().split())
xyz = [tuple(map(int, input().split())) for _ in range(n)]

s1 = abs(sum(sorted([x+y+z for x, y, z in xyz])[:m]))
s2 = abs(sum(sorted([x+y-z for x, y, z in xyz])[:m]))
s3 = abs(sum(sorted([x-y+z for x, y, z in xyz])[:m]))
s4 = abs(sum(sorted([x-y-z for x, y, z in xyz])[:m]))
s5 = abs(sum(sorted([-x+y+z for x, y, z in xyz])[:m]))
s6 = abs(sum(sorted([-x+y-z for x, y, z in xyz])[:m]))
s7 = abs(sum(sorted([-x-y+z for x, y, z in xyz])[:m]))
s8 = abs(sum(sorted([-x-y-z for x, y, z in xyz])[:m]))

print(max(s1, s2, s3, s4, s5, s6, s7, s8))

Buggy submission (verdict: Runtime Error):
import itertools
N, M = map(int, input().strip().split())
prev_cakes = []

for _ in range(M - 1):
  prev_cakes.append(tuple(map(int, input().strip().split())))

max_sum = None
for _ in range(N - M + 1):
  cake = tuple(map(int, input().strip().split()))
  for combi_cakes in itertools.combinations(prev_cakes, M - 1):
    print(combi_cakes)
    x = sum([ccake[0] for ccake in combi_cakes]) + cake[0]
    y = sum([ccake[1] for ccake in combi_cakes]) + cake[1]
    z = sum([ccake[2] for ccake in combi_cakes]) + cake[2]
    if max_sum is None or abs(x)+abs(y)+abs(z) > max_sum:
      max_sum = abs(x)+abs(y)+abs(z)
  prev_cakes.append(cake)
print(max_sum)

Buggy submission (verdict: Runtime Error):
import itertools
 
N, M = map(int, input().strip().split())
cakes = []
 
for _ in range(N):
  cake = list(map(int, input().strip().split()))
  cakes.append(abs(cake[0]) + abs(cake[1]) + abs(cake[2]))
  
print(sum(list(sorted(cakes, key=lambda x: -x)))[:M])
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
ablist = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  ablist[a-1].append((b-1, c))
  ablist[b-1].append((a-1, c))

q, k = map(int, input().split())
depth = [-1 for _ in range(n)]

def dfs(v, p, d):
  depth[v] = d
  for to, c in ablist[v]:
    if to == p:
      continue
    dfs(to, v, d + c)

dfs(k-1, -1, 0)
for _ in range(q):
  x, y = map(int, input().split())
  print(depth[x-1] + depth[y-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
ablist = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  ablist[a-1].append((b-1, c))
  ablist[b-1].append((a-1, c))

q, k = map(int, input().split())
depth = [0 for _ in range(n)]

def dfs(v, p, d):
  depth[v] = d
  for to, c in ablist[v]:
    if to == p:
      continue
    dfs(to, v, d + c)

dfs(k-1, -1, 0)
for _ in range(q):
  x, y = map(int, input().split())
  print(depth[x-1] + depth[y-1])
Problem p02859 (python)

Fixed submission:
print(int(input())**2)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
ans=1
mod=10**9+7

if (x+y)%3==0 and x<=2*y and y<=2*x:
    a=(x+y)/3
    b=(2*x-y)/3
    a=int(a)
    b=int(b)
    f=[1]
    
    for i in range(1,a+1):
        f.append(f[-1]*i%mod)
    #print(f)
    ans=f[a]//f[b]//f[a-b]  #aCbが答
    if ans>mod:
        ans=ans%mod
else:
    ans=0
print(int(ans))
Problem p03038 (python)

Fixed submission:
from operator import itemgetter

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[]

for i in range(m):
    x=list(map(int,input().split()))
    bc.append(x)

a.sort()
bc.sort(key=itemgetter(1),reverse=True)

k=0
for i in range(m):
    b=bc[i][0]
    c=bc[i][1]
    for j in range(b):
        if(a[k]>c):
            break
        a[k]=c
        k+=1
        if(k>n-1):
            break
    else:
        continue
    break

print(sum(a))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

from operator import itemgetter

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[]

for i in range(m):
    x=list(map(int,input().split()))
    bc.append(x)

a.sort()
bc.sort(key=itemgetter(1),reverse=True)

k=0
for i in range(m):
    b=bc[i][0]
    c=bc[i][1]
    for j in range(b):
        if(a[k]>c):
            break
        a[k]=c
        k+=1
    else:
        continue
    break

print(sum(a))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[]

for i in range(m):
    x=list(map(int,input().split()))
    bc.append(x)

a.sort()
bc.sort(key=itemgetter(1),reverse=True)

k=0
for i in range(m):
    while(bc[i][0]>0):
        j=bc[i][0]
        c=bc[i][1]
        if(j==0):
            break
        if(a[k]>c):
            break
        a[k]=c
        bc[i][0]-=1
        k+=1
    else:
        continue
    break

print(sum(a))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[]

for i in range(m):
    x=list(map(int,input().split()))
    bc.append(x)

a.sort()
bc.sort(key=itemgetter(1),reverse=True)

k=0
for i in range(m):
    while(bc[i][0]>0):
        j=bc[i][0]
        c=bc[i][1]
        print([j,c])
        if(j==0):
            break
        if(a[k]>c):
            break
        a[k]=c
        bc[i][0]-=1
        k+=1
    else:
        continue
    break

print(sum(a))
Problem p03242 (python)

Fixed submission:
print(input().replace('1','a').replace('9','1').replace('a','9'))

Buggy submission (verdict: Runtime Error):
s=input()
for i in range(3):
  if s[i]=='1':
    s[i]='9'
  else:
    s[i]='1'
print(s)
Problem p03326 (python)

Fixed submission:
import numpy as np

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

x_arr=[]
y_arr=[]
z_arr=[]
for i in range(N):
	x,y,z=input().split(' ')
	x=int(x)
	y=int(y)
	z=int(z)
	x_arr.append(x)
	y_arr.append(y)
	z_arr.append(z)

x_arr=np.array(x_arr)
y_arr=np.array(y_arr)
z_arr=np.array(z_arr)

xyz1=x_arr+y_arr+z_arr
xyz1=np.sort(xyz1)[::-1]
xyz1_sum=np.sum(xyz1[:M:])

xyz2=x_arr+y_arr-z_arr
xyz2=np.sort(xyz2)[::-1]
xyz2_sum=np.sum(xyz2[:M:])

xyz3=x_arr-y_arr-z_arr
xyz3=np.sort(xyz3)[::-1]
xyz3_sum=np.sum(xyz3[:M:])

xyz4=x_arr-y_arr+z_arr
xyz4=np.sort(xyz4)[::-1]
xyz4_sum=np.sum(xyz4[:M:])

xyz5=-x_arr-y_arr+z_arr
xyz5=np.sort(xyz5)[::-1]
xyz5_sum=np.sum(xyz5[:M:])

xyz6=-x_arr+y_arr+z_arr
xyz6=np.sort(xyz6)[::-1]
xyz6_sum=np.sum(xyz6[:M:])

xyz7=-x_arr+y_arr-z_arr
xyz7=np.sort(xyz7)[::-1]
xyz7_sum=np.sum(xyz7[:M:])

xyz8=-x_arr-y_arr-z_arr
xyz8=np.sort(xyz8)[::-1]
xyz8_sum=np.sum(xyz8[:M:])

a=[xyz1_sum,xyz2_sum,xyz3_sum,xyz4_sum,xyz5_sum,xyz6_sum,xyz7_sum,xyz8_sum]
print(max(a))

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

x_arr=[]
y_arr=[]
z_arr=[]
for i in range(N):
	x,y,z=input().split(' ')
	x=int(x)
	y=int(y)
	z=int(z)
	x_arr.append(x)
	y_arr.append(y)
	z_arr.append(z)

ans_x=0
ans_y=0
ans_z=0
for i in range(M):
	kari_arr=[]
	for j in range(N-i):
		ans_x1=ans_x+x_arr[j]
		ans_y1=ans_y+y_arr[j]
		ans_z1=ans_z+z_arr[j]
		kari_arr.append(abs(ans_x1)+abs(ans_y1)+abs(ans_z1))
	print(kari_arr)
	index=kari_arr.index(max(kari_arr))
	ans_x=ans_x+x_arr[index]
	ans_y=ans_y+y_arr[index]
	ans_z=ans_z+z_arr[index]
	del x_arr[index]
	del y_arr[index]
	del z_arr[index]
	ans=abs(ans_x)+abs(ans_y)+abs(ans_z)
print(ans)
Problem p03329 (python)

Fixed submission:
N=int(input())

def num_6(A):
	i=0
	while True:
		if 6**i>A:
			return i-1
		i=i+1

def num_9(A):
	i=0
	while True:
		if 9**i>A:
			return i-1
		i=i+1

num_arr=[]
for i in range(N+1):
	num_6_max=num_6(i)
	num_9_max=num_9(N-i)
	a6_num=[]
	a9_num=[]
	A=i
	B=N-(i)
	for j in range(num_6_max+1):
		a6_num.append(A//(6**(num_6_max-j)))
		A=A-(6**(num_6_max-j))*a6_num[j]
	for j in range(num_9_max+1):
		a9_num.append(B//(9**(num_9_max-j)))
		B=B-(9**(num_9_max-j))*a9_num[j]
	num_arr.append(sum(a6_num)+sum(a9_num))
print(min(num_arr))

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

def num_6(A):
	i=0
	while True:
		if 6**i>A:
			return i-1
		i=i+1

def num_9(A):
	i=0
	while True:
		if 9**i>A:
			return i-1
		i=i+1

num_arr=[]
for i in range(N-1):
	num_6_max=num_6(i+1)
	num_9_max=num_9(N-(i+1))
	a6_num=[]
	a9_num=[]
	A=i+1
	B=N-(i+1)
	for j in range(num_6_max+1):
		a6_num.append(A//(6**(num_6_max-j)))
		A=A-(6**(num_6_max-j))*a6_num[j]
	for j in range(num_9_max+1):
		a9_num.append(B//(9**(num_9_max-j)))
		B=B-(9**(num_9_max-j))*a9_num[j]
	num_arr.append(sum(a6_num)+sum(a9_num))
print(min(num_arr))

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

def num_6(A):
	i=0
	while True:
		if 6**i>A:
			return i-1
		i=i+1

def num_9(A):
	i=0
	while True:
		if 9**i>A:
			return i-1
		i=i+1

num_arr=[]
for i in range(N-1):
	num_6_max=num_6(i+1)
	num_9_max=num_9(N-(i+1))
	a6_num=[]
	a9_num=[]
	A=i+1
	B=N-(i+1)
	for j in range(num_6_max+1):
		a6_num.append(A//(6**(num_6_max-j)))
		A=A-(6**(num_6_max-j))*a6_num[j]
	for j in range(num_9_max+1):
		a9_num.append(B//(9**(num_9_max-j)))
		B=B-(9**(num_9_max-j))*a9_num[j]
	num_arr.append(sum(a6_num)+sum(a9_num))
print(min(num_arr))
Problem p02547 (python)

Fixed submission:
n=int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
a=0
for i in range(n):
  if x[i]==y[i]:
    a+=1
    if a==3:
      break
  else:
    a=0
    
if a>=3:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
a=0
for i in range(n):
  if x[i]==y[i]:
    a+=1
  	if a==3:
      break
  else:
    a=0
    
if a>=3:
  print("Yes")
else:
  print("No")
Problem p02577 (python)

Fixed submission:
n=input()
a=len(n)
b=0
for i in range(a):
  b=b+int(n[i])
if b%9==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=input()
a=len(b)
b=0
for i in range(a):
  b=b+int(n[i])
if b%9==0:
  print("Yes")
else:
  print("No")
Problem p02777 (python)

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u=input()
if s==u:
  print(a-1,b)
else:
  print(a,b-1)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input().split())
u=input()
if s==u:
  print(s-1 t)
else:
  print(s t-1)
Problem p02570 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
D, T, S = map(int, input().split())
if D/S <= T:
  print("Yes")
else:
  print("No")

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

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

sum_A = sum(A) % mod
ans = 0
for a in A[:-1]:
  sum_A -= a
  sum_A %= mod
  ans += a * sum_A
  ans %= mod

ans %= mod
print(ans)

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

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

sum_A = sum(A) % mod
ans = 0
for a in A[:-1]:
  sum_A -= a
  sum_A %= mod
  ans += a * sum_A
  ans %= mod

ans %= mod
print(ans)
Problem p02571 (python)

Fixed submission:
import sys
input = sys.stdin.readline
S = input().strip()
T = input().strip()
score_list = []
for i in range(len(S) - len(T) + 1):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_list))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline.strip()
S = input()
T = input()
score_list = []
for i in range(len(S) - len(T) + 1):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_list))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
S = input()
T = input()
score_list = []
for i in range(len(S) - len(T)):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_list))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
S = input()
T = input()
score_list = []
diff = len(S) - len(T)
len_T = len(T)
for i in range(0, diff):
  s = S[i:i+len_T]
  score = sum([1 if s[i]==T[i] else 0 for i in range(len(s))])
  score_list.append(score)

print(len_T - max(score_list))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
S = input()
T = input()
score_list = []
for i in range(0, len(S)-len(T)):
  s = S[i:i+len(T)]
  score = sum([1 if s[i]==T[i] else 0 for i in range(len(s))])
  score_list.append(score)
print(len(T) - max(score_list))
Problem p02580 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  Hsum[h] += 1
  Wsum[w] += 1
  hw.add((h, w))

mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) if _ == mh]
widx = [i for i, _ in enumerate(Wsum) if _ == mw]
 
if len(hidx) * len(widx) > M:
  print(mh + mw)
else:
  fi_flg = False
  for h in hidx:
    for w in widx:
      if (h, w) not in hw:
        print(mh + mw)
        fi_flg = True
        break
    if fi_flg:
      break
  if fi_flg is False:
    print(mh + mw - 1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  Hsum[h] += 1
  Wsum[w] += 1
  hw.add((h, w))

mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) if _ == mh]
widx = [i for i, _ in enumerate(Wsum) if _ == mw]

if len(hidx) * len(widx) > M:
  print(mh + mw)
else:
  fi_flg = False
  for h in hidx:
    for w in widx:
      if (h, w) not in hw:
        print(mh + mw)
        fi_flg = True
        break
    if fi_flg:
      break
if fi_flg is False:
  print(mh + mw - 1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  Hsum[h] += 1
  Wsum[w] += 1
  hw.add((h, w))

mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) if _ == mh]
widx = [i for i, _ in enumerate(Wsum) if _ == mw]

if len(hidx) * len(widx) > M:
  print(mh + mw)
else:
  fi_flg = False
  for h in hidx:
    for w in widx:
      if (h, w) not in hw:
        print(mh + mw)
        fi_flg = True
        break

if fi_flg is False:
  print(mh + mw - 1)

Buggy submission (verdict: Runtime Error):
import random
import itertools
import sys
def input():
    return sys.stdin.readline()[:-1]
  
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = []
for m in range(M):
  h, w = map(int, input().split())
  #h = random.randint(0, H)
  #w = random.randint(0, W)
  Hsum[h-1] += 1
  Wsum[w-1] += 1
  hw.append(str(h-1)+"_"+str(w-1))

hmax_ind = list(map(lambda x: True if x == max(Hsum) else False, Hsum))
hmax_ind = list(itertools.compress(range(len(Hsum)), hmax_ind))
wmax_ind = list(map(lambda x: True if x == max(Wsum) else False, Wsum))
wmax_ind = list(itertools.compress(range(len(Wsum)), wmax_ind))
 
res = []
for n in itertools.product(hmax_ind, wmax_ind):
  res.append(str(n[0])+"_"+str(n[1]))

if len(set(res).intersection(set(hw))) == len(res):
  print(max(Hsum) + max(Wsum)-1)
else:
  print(max(Hsum) + max(Wsum)
Problem p02627 (python)

Fixed submission:
a = input()

if str.isupper(a):
    print('A')
elif str.islower(a):
    print('a')

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

chars = "0abcdefghijklmnopqrstuvwxyz"
a = ""
n_1 = N

while True:
    x = N % 26

    if x == 0:
        x = 26

    a += chars[x]
    n_1 -= x
    if n_1 == 0:
        break

    n_1 //= 26

print(a[::-1])
Problem p02629 (python)

Fixed submission:
n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  

n_rem = n  
res = ""

while True:
    x = n_rem % 26
   
    if x == 0:
        x = 26
    res += chars[x]

    
    n_rem -= x

    
    if n_rem == 0:
        break

    n_rem //= 26


print(res[::-1])

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

chars = "0abcdefghijklmnopqrstuvwxyz"
a = ""
n_1 = N

while True:
    x = n_1 % 26

    if x == 0:
        x = 26

    a += chars[x]
    n_1 -= x
    if n_1 == 0:
        break

    n //= 26

print(a[::-1])

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

chars = "0abcdefghijklmnopqrstuvwxyz"
a = ""
n = N

while True:
    x = n_1 % 26

    if x == 0:
        x = 26

    a += chars[x]
    n_1 -= x
    if n_1 == 0:
        break

    n //= 26

print(n[::-1])

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

chars = "0abcdefghijklmnopqrstuvwxyz"
a = ""
n = N

while True:
    x = N % 26

    if x == 0:
        x = 26

    a += chars[x]
    n -= x
    if n == 0:
        break

    n //= 26

print(n[::-1])
Problem p02659 (python)

Fixed submission:
print(int((s:=input())[:-4])*int(s[-4]+s[-2:])//100)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = int(b.strip("."))
print(a*b//100)
Problem p02570 (python)

Fixed submission:
D, T, S = map(int, input().split())

if D <= T * S:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
D = int(input())
T = int(input())
S = int(input())

if D <= T * S:
    print("Yes")
else:
    print("NO")
Problem p02550 (python)

Fixed submission:
import sys
n,x,m=map(int,input().split())
a=[0]*(m+2)
cnt=[0]*(m+2)
a[1],f=x,x
cnt[f]=1
if x==0:
  print(0)
  sys.exit()
for i in range(2,m+1):
  f=f*f%m
  a[i]=f
  if cnt[f]==0:
    cnt[f]=1
  else:
    break
ind=a[1:].index(f)+1
ans=sum(a[:ind])+sum(a[ind:i])*((n-ind+1)//(i-ind))
p=(n-ind+1)%(i-ind)
ans+=sum(a[ind:ind+p])
print(ans)

Buggy submission (verdict: Runtime Error):
n,x,m=map(int,input().split())
a=[0]*(m+2)
cnt=[0]*(m+2)
a[1],f=x,x
cnt[f]=1
for i in range(2,m+1):
  f=f*f%m
  a[i]=f
  if cnt[f]==0:
    cnt[f]=1
  else:
    break
ind=a[1:].index(f)+1
ans=sum(a[:ind])+sum(a[ind:i])*((n-ind+1)//(i-ind))
p=(n-ind+1)%(i-ind)
ans+=sum(a[ind:ind+p])
print(ans)

Buggy submission (verdict: Runtime Error):
n,x,m=map(int,input().split())
a=[0]*(m+2)
cnt=[0]*(m+2)
a[1],f=x,x
cnt[f]=1
for i in range(2,m):
  f=f*f%m
  a[i]=f
  if cnt[f]==0:
    cnt[f]=1
  else:
    break
ind=a[1:].index(f)+1
ans=sum(a[:ind])+sum(a[ind:i])*((n-ind+1)//(i-ind))
p=(n-ind+1)%(i-ind)
ans+=sum(a[ind:ind+p])
print(ans)