Harryxun/stf_run huggingface dataset:
from collections import Counter

N = int(input())
S = input()

a, b, c = Counter(S).values()
r = a*b*c

for i in range(N):
    for j in range(i+1, N):
        k = 2*j-i
        # print(i, j, k)
        if k < N and len({S[i], S[j], S[k]}) == 3:
            r -= 1

print(r)

### FIXED CODE ###

from collections import Counter

N = int(input())
S = input()

counter = Counter(S)

r = 1
for c in "RGB":
    r *= counter[c]


for i in range(N):
    for j in range(i+1, N):
        k = 2*j-i
        # print(i, j, k)
        if k < N and len({S[i], S[j], S[k]}) == 3:
            r -= 1

print(r)
import math
a, b = list(map(int,input().split()))
print(int(a * b // math.gcd(a, b)))

### FIXED CODE ###

from fractions import gcd
a, b = list(map(int,input().split()))
print(int(a * b//gcd(a, b)))
N = int(input())
S = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    s = input()
    if s[0] in ["M","A","R","C","H"]
        S[s[0]] += 1

print(S["M"] * S["A"] * (S["R"]+S["C"]+S["H"]) + S["M"] * S["R"] * (S["C"] + S["H"]) + S["M"] * S["C"] * S["H"] + S["A"] * S["R"] * (S["C"] + S["H"]) + S["C"] * S["A"] * S["H"] +  S["R"] * S["C"] * S["H"])


### FIXED CODE ###

N = int(input())
S = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in range(N):
    s = input()
    if s[0] in ["M","A","R","C","H"]:
        S[s[0]] += 1

print(S["M"] * S["A"] * (S["R"] + S["C"] + S["H"])
      + S["M"] * S["R"] * (S["C"] + S["H"])
      + S["M"] * S["C"] * S["H"]
      + S["A"] * S["R"] * (S["C"] + S["H"])
      + S["A"] * S["C"] * S["H"]
      + S["R"] * S["C"] * S["H"])
x,y = map(int,input().split())
print(min(abs(y-x),abs(x+y)+1)

### FIXED CODE ###

x,y = map(int,input().split())
if abs(x) == abs(y):
  print(0 if x == y else 1)
elif x < y:
  print(min(y - x,abs(y + x) + 1))
else:
  print(min(abs(y+x),abs(y-x))+ 1 if x * y <= 0 else min(abs(y+x),abs(y-x))+ 2)
input_data = input()
N, Y = map(int, input_data.split())
result = False
count_10000 = 0
count_5000 = 0
count_1000 = 0

for count_10000 in range(0, N + 1):
    for count_5000 in range(0, N + 1 - count_10000):
        count_1000 = N - count_10000 - count_5000
        total = count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000
        count = count_10000 + count_5000 + count_1000
        if total == Y and count == N:
            result = True
            break
    else:
        continue
    break

if result:
    print(f"{count_10000} {count_5000} {count_1000}")
else:
    print("-1 -1 -1")

### FIXED CODE ###

input_data = input()
N, Y = map(int, input_data.split())
result = False
count_10000 = 0
count_5000 = 0
count_1000 = 0

for count_10000 in range(0, N + 1):
    for count_5000 in range(0, N + 1 - count_10000):
        count_1000 = N - count_10000 - count_5000
        total = count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000
        count = count_10000 + count_5000 + count_1000
        if total == Y and count == N:
            result = True
            break
    else:
        continue
    break

if result:
    print("{} {} {}".format(count_10000, count_5000, count_1000))
else:
    print("-1 -1 -1")
H = int(input(""))
A = int(input(""))

i = 0
while H > 0:
    H -= A
    i += 1

print(i)

### FIXED CODE ###

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

i = 0
while H > 0:
    H -= A
    i += 1

print(i)
from decimal import *
getcontext().prec = 16

n = float(input())
a = list(map(float, input().split()))

s = 1
for i in a:
    s = s * i

x = (n-1)*sum(a)
print(Decimal(s)/Decimal(x))

### FIXED CODE ###

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

for i in a:
    ans = ans + 1/i
print(1/ans)
n,m,k=map(int,input().split())
data2=list(map(int,input().split()))
data3=list(map(int,input().split()))

data2cnt=0
data3cnt=0
total=0
count=0
maxint=n+m

for i in range(maxint):

  if len(data2)>=data2cnt+1 and int(data2[data2cnt]) < int(data3[data3cnt]):
      if k>=total+data2[data2cnt]:
        total=total+int(data2[data2cnt])
        data2cnt=data2cnt+1
  elif len(data3)>=data3cnt+1:
      if k>=total+data3[data3cnt]:
        total=total+int(data3[data3cnt])
        data3cnt=data3cnt+1
print(str(data2cnt+data3cnt))


### FIXED CODE ###

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

#片方の机から何も選ばれない場合での配列を作成
a, b = [0], [0]
for i in range(len(A)):
    a.append(a[i]+A[i])
for i in range(len(B)):
    b.append(b[i]+B[i])
#すべてJの場合から減らしていく
ans,j=0,M
for i in range(N+1):
    if a[i] > K:
        break
    #すべてBの総和がK-a[i]より小さくなるjを測定
    while b[j] > K - a[i]:
        j -= 1
    #i+jとansのうち大きい方を答えにする。
    ans= max(ans,i+j)

print(ans)
import sys

sys.setrecursionlimit(4100000)

def biser(lst,func):
    n=len(lst)
    nh=n//2
    if n==1:
        if func(lst[0]):
            return lst[0]
        else:
            return -1
    if func(lst[nh]):
        return biser(lst[nh:],func)
    else:
        return biser(lst[:nh],func)

def findminsum(lst,K,N):
    inf=10**6
    dp=[[inf]*N for s in range(K+1)]
    for s in range(K+1):
        for j in range(N):
            if j==0 and s<=lst[j]:
                dp[s][j]=lst[0]
            elif s>lst[j] and j>0:
                dp[s][j]=min(dp[s-lst[j]][j-1]+lst[j], dp[s][j-1])
            elif s<=lst[j] and j>0:
                dp[s][j]=min(lst[j],dp[s][j-1])
    # print(lst)
    # print(dp[0][:])
    # print(dp[1][:])
    # print(dp[K][:])
    return dp[K][N-1]


def main():
    N,K=map(int,sys.stdin.readline().strip().split())
    cards=list(map(int,sys.stdin.readline().strip().split()))
    # cards=list(filter(lambda x:x<K,cards))
    # N=len(cards)
    cards.sort()
    ci=list(range(N))
    def func(h):
        c=cards[h]
        cards[h]=0
        ret=findminsum(cards,K-c,N)>=K
        cards[h]=c
        return ret
    #nn=0
    nn=biser(ci,func)
    # for i in range(N):
    #     if cards[i]<K:
    #         c=cards[i]
    #         cards[i]=0
    #         if findminsum(cards,K-c,N)>=K:
    #             nn+=1
    #         cards[i]=c
    #     else:
    #         break
    print(nn+1)

if __name__=='__main__':
    main()


### FIXED CODE ###

#4 9
#1 3 5 6
#の時に1（正解は0）と出力されるがACになる

N, K = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
ans = N
t = 0
for i in range(N-1, -1, -1) :
  if t+a[i] < K:
    t += a[i]
  else:
    ans = min(ans, i)
print(ans)
N, A, B = map(int, input().rstrip().split())
print((N//(A+B) * A + ('b'*A+'r'*B)[:(N % (A+B))].count('b')))


### FIXED CODE ###

N, A, B = map(int, input().rstrip().split())
if A == 0:
    ret = 0
elif A + B == 0:
    ret = 0
else:
    tmp1 = int(N / (A + B)) * A
    tmp2 = 0
    if A > N % (A + B):
        tmp2 = N % (A + B)
    else:
        tmp2 = A
    ret = tmp1 + tmp2
print(ret)
N = int(input())
A = list(map(int, input().split()))


count = 0
for i in range(len(A) - 2):
    if (A[i] > A[i + 1]) and (A[i + 1] > A[i + 2]):
       count += 1
    elif (A[i + 2] > A[i + 1]) and (A[i + 1] > A[i]):
        count += 1
    else: 
        pass
print(count)

### FIXED CODE ###

import collections

s = input()

if list(collections.Counter(list(s)).values()) == [2, 2]:
    print("Yes")
else:
    print("No")
def acinput():
    return list(map(int,input().split(" ")))


N=int(input())
s=acinput()

s.insert(0,0)
dp=[0]*(N+1)
#dp[0]=int(1==s[0])

for i in range(1,N+1):
    if s[i]==i:
        dp[i]=dp[i-1]+1
        try:
            s[i+1]=s[i]
        except e:
            pass
    else:
        dp[i]=dp[i-1]
print(dp[-1])


### FIXED CODE ###

def spaceinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=spaceinput()

a.insert(0,0)

count=0
for i in range(1,len(a)-1):
    #print(i,a)
    if i==len(a)-2:
        #print(a,N)
        if a[-1]==N:
            count+=1
            break

    if i==a[i]:
        count+=1
        s=a[i]
        a[i]=a[i+1]
        a[i+1]=s


print(count)
# -*- coding: utf-8 -*-
n,q = map(int,input().split())
a_b_list = [list(map(int,input().split())) for i in range(n-1)]
p_x_list = [list(map(int,input().split())) for i in range(q)]

graph_direct_list = [[] for _ in range(n+1)]
for i in range(n-1):
    a_i = a_b_list[i][0]
    b_i = a_b_list[i][1]
    graph_direct_list[a_i].append(b_i)
    graph_direct_list[b_i].append(a_i)

counter_init_list = [0 for _ in range(n+1)]


for j in range(q):
    p_j = p_x_list[j][0]
    x_j = p_x_list[j][1]
    counter_init_list[p_j] += x_j

counter_list = [0 for _ in range(n+1)]
graph_vertex_checked_list = [0 for _ in range(n+1)]


graph_vertex_stack_que=collections.deque()
graph_vertex_stack_que.append(1) # start
while graph_vertex_stack_que:
    v = graph_vertex_stack_que.pop()
    graph_vertex_checked_list[v] = 1
    counter_list[v] += counter_init_list[v]
    for u in graph_direct_list[v]:
        if graph_vertex_checked_list[u] == 1:
            continue
        counter_list[u] += counter_list[v]
        graph_vertex_stack_que.append(u)
print(*counter_list[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
import collections
n,q = map(int,input().split())
a_b_list = [list(map(int,input().split())) for i in range(n-1)]
p_x_list = [list(map(int,input().split())) for i in range(q)]

graph_direct_list = [[] for _ in range(n+1)]
for i in range(n-1):
    a_i = a_b_list[i][0]
    b_i = a_b_list[i][1]
    graph_direct_list[a_i].append(b_i)
    graph_direct_list[b_i].append(a_i)

counter_init_list = [0 for _ in range(n+1)]


for j in range(q):
    p_j = p_x_list[j][0]
    x_j = p_x_list[j][1]
    counter_init_list[p_j] += x_j

counter_list = [0 for _ in range(n+1)]
graph_vertex_checked_list = [0 for _ in range(n+1)]


graph_vertex_stack_que=collections.deque()
graph_vertex_stack_que.append(1) # start
while graph_vertex_stack_que:
    v = graph_vertex_stack_que.pop()
    graph_vertex_checked_list[v] = 1
    counter_list[v] += counter_init_list[v]
    for u in graph_direct_list[v]:
        if graph_vertex_checked_list[u] == 1:
            continue
        counter_list[u] += counter_list[v]
        graph_vertex_stack_que.append(u)
print(*counter_list[1:])
r, c = [int(i) for i in input().split()]
data = [[int(i) for i in input().split()] for j in range(r))]
ans = [data[i] + [sum(data[i])] for i in range(r)]
last_ans = ans + [[sum([ans[i][j] for i in range(r)]) for j in range(c+1)]]
for i in last_ans:
    print(*i)


### FIXED CODE ###

r, c = [int(i) for i in input().split()]
data = [[int(i) for i in input().split()] for j in range(r)]
ans = [data[i] + [sum(data[i])] for i in range(r)]
last_ans = ans + [[sum([ans[i][j] for i in range(r)]) for j in range(c+1)]]
for i in last_ans:
    print(*i)
X = int(input())
Y = int(input())
Z = int(input())
print(Z, X, Y)

### FIXED CODE ###

X, Y, Z = list(map(int, input().split()))
X, Y, Z = Z, X, Y
print(X, Y, Z)
n=int(input()
p=list(map(int, input().split()))
i=0
for x in range(0,n-2):
    if p[x]>p[x+1] and p[x+1]>p[x+2]:
        i=i+1
    if p[x]<p[x+1] and p[x+1]<p[x+2]:
        i=i+1
    if p[x]==p[x+1] and p[x+1]<p[x+2]:
        i=i+1
    if p[x]>p[x+1] and p[x+1]==p[x+2]:
        i=i+i
print(i)


### FIXED CODE ###

n=int(input())
p=list(map(int, input().split()))
i=0
for x in range(0,n-2):
    if p[x]>p[x+1] and p[x+1]>p[x+2]:
        i=i+1
    if p[x]<p[x+1] and p[x+1]<p[x+2]:
        i=i+1
    if p[x]==p[x+1] and p[x+1]<p[x+2]:
        i=i+1
    if p[x]>p[x+1] and p[x+1]==p[x+2]:
        i=i+i
print(i)
S = list(input())
T = list(input())
defolt = 1000
for i in range(len(S)-len(T)):
    ans = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            ans += 1
        ans = min(defolt,ans)
print(ans)

### FIXED CODE ###

S = list(input())
T = list(input())
defolt = 1000
for i in range(len(S)-len(T)+1):
    ans = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            ans += 1
    defolt = min(defolt,ans)
print(defolt)
n, y = list(map(int, input().split()))

a = -1
b = -1
c = -1

for i in range(n+1):
    for j in range(n+1-i):
        if i*1000 + j*5000 + (n-i-j)*10000 == y:
            a, b, c = i, j, n-i-j
            break
print(c, b, a)

### FIXED CODE ###

s = input()

a = s[0:3] + "8" + s[4:]
print(a)
X,K,D = map(int, input().split())
Ans = 0

if abs(X) >= K * D:
  if X >= 0:
    Ans = X - (K * D)
  else:
    Ans = abs(X + (K * D))
    
else:
  abX = abs(X)
#  if X >= 0:
  if (K - abX // D) % 2 == 0:
      Ans = abX - ((abX // D) * D)
    else:
      Ans = abs(abX - ((abX // D) * D) - D)
      
#  else:
#    print(abs(X // D))
#    if (K - abs(X // D)) % 2 == 0:
#      Ans = abs(X + (abs((X // D)) * D))
#    else:
#      Ans = abs(X + (abs((X // D)) * D) - D)
    
print(Ans)


### FIXED CODE ###

X,K,D = map(int, input().split())
Ans = 0

if abs(X) >= K * D:
  if X >= 0:
    Ans = X - (K * D)
  else:
    Ans = abs(X + (K * D))
    
else:
  abX = abs(X)
#  if X >= 0:
  if (K - abX // D) % 2 == 0:
    Ans = abX - ((abX // D) * D)
  else:
    Ans = abs(abX - ((abX // D) * D) - D)
      
#  else:
#    print(abs(X // D))
#    if (K - abs(X // D)) % 2 == 0:
#      Ans = abs(X + (abs((X // D)) * D))
#    else:
#      Ans = abs(X + (abs((X // D)) * D) - D)
    
print(Ans)
n=int(input())
x=list(input().split() for _ in range(n))
ans=0
for i in range(n):
  if str(x[i][1])=="JPY":
    ans+=int(x[i][0])
  else:
    ans+=int(x[i][0])*380000
    
print(ans)    
  



### FIXED CODE ###

n=int(input())
x=list(input().split() for _ in range(n))
ans=0
for i in range(n):
  if str(x[i][1])=="JPY":
    ans+=float(x[i][0])
  else:
    ans+=float(x[i][0])*380000
    
print(ans)
import numpy as np

if __name__=="__main__":
    inputs_number  = lambda : [int(x) for x in input().split()]
    N, Ma, Mb = inputs_number()
    drugs = [inputs_number() for i in range(N)]
    inf = 100*N + 1
    dp = np.ones((N+1,N*10+1,N*10+1)) * inf
    dp[0,0,0] = 0.0

    for i in range(N):
	for ca in range(N*10+1):
            for cb in range(N*10+1):
		if(dp[i,ca,cb]==inf):
                    continue
                dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]])
                dp[i+1,ca+drugs[i][0],cb+drugs[i][1]]=np.min([dp[i+1,ca+drugs[i][0],cb+drugs[i][1]],dp[i,ca,cb]+drugs[i][2]])

### FIXED CODE ###

if __name__=="__main__":
    a, b = list(map(int, input().split(" ")))
    if(a==1):
        a = 14
    if(b==1):
        b = 14
    if(a > b):
        print("Alice")
    elif(a == b):
        print("Draw")
    else:
        print("Bob")
n=int(input())
s=[list(map(int,list(input().split()))) for i in range(n)]  # 二次元配列入力　二次元マップみたいな入力のとき

import math
from functools import lru_cache

@lru_cache(maxsize=100000)
def calc_distance(a, b):
    tmp = (a[0]-b[0])**2 + (a[1]-b[1])**2
    return math.sqrt(tmp)


import itertools
sum = 0
for all in itertools.permutations(s, 3):
    for i in range(n-1):
        # tupleにすることで、lru_cacheを使用可能にする．
        # listはハッシュ出来ないが、tupleはハッシュ可能．
        sum += calc_distance(tuple(all[i]), tuple(all[i+1])) 

kaizyo = math.factorial(n)
# print("sum:", sum)
# print("kaizyo:", kaizyo)

print(sum/kaizyo)

### FIXED CODE ###

n=int(input())
s=[list(map(int,list(input().split()))) for i in range(n)]  # 二次元配列入力　二次元マップみたいな入力のとき

# print("n", n)
# print("s:", s)

import math

def calc_distance(a, b):
    tmp = (a[0]-b[0])**2 + (a[1]-b[1])**2
    return math.sqrt(tmp)

sum = 0
for i in s: 
    for j in s:
        dist = calc_distance(i, j)
        sum += dist

print(float(sum/n))
a,b,c=[int(x) for x in input().split()]

count=0
for d in xrange(a,b+1):
    if c%d==0: count+=1
print(count)



### FIXED CODE ###


x=input().split()
a=int(x[0])
b=int(x[1])
c=int(x[2])

count=0
for d in range(a,b+1):
    if c%d==0: count+=1
print(count)
N, K = map(int, input().split())
S = input()

res = 0
pre = None
add = {2: 0}
if S[0] == S[-1] and S[0] == "L":
    add[0] = 1
else:
    add[0] = 0
for s in S:
    if pre is None:
        pass
    elif pre == s:
        res += 1
    elif pre == "R":
        add[2] += 1
    pre = s

if add[2] > K:
    res += 2 * K
    print(res)
else:
    res += 2 * add[2]
    K -= add[2]
    if K > 0:
        res += add[1]
    print(res)





### FIXED CODE ###

N, K = map(int, input().split())
S = input()

res = 0
pre = None
add = {2: 0}
add[1] = 0 if S[0] == S[-1] else 1
for s in S:
    if pre is None:
        pass
    elif pre == s:
        res += 1
    elif pre == "R":
        add[2] += 1

    pre = s

if add[2] > K:
    res += 2 * K
    print(res)
else:
    res += 2 * add[2]
    K -= add[2]
    if add[1] == 1 and S[-1] == "L":
        res -= 2
    if K > 0:
        res += add[1]
    print(res)
s = input()
t = input()

s.sort()
t.sort(reverse=True)
s = ''.join(s)
t = ''.join(t)
if s < t:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)
s = ''.join(s)
t = ''.join(t)
if s < t:
    print('Yes')
else:
    print('No')
N, H, W = map(int, input().split())

print((N-H+1)*(N-W+1))

### FIXED CODE ###

N = int(input())
H = int(input())
W = int(input())
 
print((N-H+1)*(N-W+1))
def fio(x,y):
    return x+y

n_a,m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))

n = [0,1,2]

for i in range(1,100000):
    n.append(fio(n[i],n[i+1]))

last_break = 0
ans = 1
ans = ans * n[a[0]-last_break-1]
ans = ans % 1000000007
last_break = a[0]

if a[0] == 1:
    ans = 1
    
for i in range(1,m):
    ans = ans * n[max(0,a[i]-last_break-2)]
    ans = ans % 1000000007
    last_break = a[i]
    
ans = ans * n[n_a-last_break-1]
ans = ans % 1000000007
if m == 0:
    ans = n[n_a]
    ans = ans % 1000000007
print(ans)


### FIXED CODE ###

n,m = map(int,input().split())
a = []
mod = 10**9+7
for i in range(m):
    temp = int(input())
    a.append(temp)

a.append(0)
dp = [0]*(n+1)
dp[0] = 1
if a[0] == 1:
    dp[1] = 0
    l = 1
else:
    dp[1] = dp[0]
    l = 0
    
for i in range(2,n+1):
    if a[l] != i:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i]%=mod 
    else:
        l += 1

print(dp[-1])
h,w=[int(i) for i in input().split()]
for i in range(w):
    lst=[i for i in input().split()]
    for j in lst:
        print(j)
    for j in lst:
        print(j)

### FIXED CODE ###

h,w=[int(i) for i in input().split()]
for i in range(h):
    lst=[i for i in input().split()]
    for j in lst:
        print(j)
    for j in lst:
        print(j)
s=input()
s[3]=8
print(s)

### FIXED CODE ###

s=list(input())
s[3]="8"
ans=""
for i in range(len(s)):
  ans+=s[i]
print(ans)
a,b=map(int,input().split())
if a*B%2==0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
if a*b%2==0:
    print("Even")
else:
    print("Odd")
from collections import deque
def main():
    H, W = map(int,input().split())
    s = [list(map(str,input())) for _ in range(W)]
    dist = [[-1]*W for _ in range(H)]
    
    q = deque([])
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                dist[i][j] = 0
                q.append((i, j))
    
    ans = 0
    while q:
        x, y = q.popleft()
        dx = [1, -1, 0, 0]
        dy = [0, 0, 1, -1]
        for i in range(4):
            nx = x+dx[i]
            ny = y+dy[i]
            if (0 <= nx < H and 0 <= ny < W and dist[nx][ny] == -1 and s[nx][ny] == '.'):
                dist[nx][ny] = dist[x][y] + 1
                q.append((nx, ny))
                ans = max(ans, dist[nx][ny])
                
    print(ans)

if __name__ == "__main__":
    main()
                

### FIXED CODE ###

import numpy
H,W = map(int,input().split())
a_list = []
INF = 10**10
for i in range(H):
    str = input()
    a_list.append([0 if i == "#" else INF for i in list(str)])

a_list = numpy.array(a_list)
for x in range(W-1):
    a_list[:,x+1] = numpy.minimum(a_list[:,x]+1,a_list[:,x+1])
    a_list[:,-x-2] = numpy.minimum(a_list[:,-x-1]+1,a_list[:,-x-2])

for y in range(H-1):
    a_list[y+1,:] = numpy.minimum(a_list[y,:]+1,a_list[y+1,:])
    a_list[-y-2,:] = numpy.minimum(a_list[-y-1,:]+1,a_list[-y-2,:])

print(a_list.max())
H,W,M = map(int,input().split())
m =[[0]*W for _ in range (H)]
hlist = [0]*H
wlist = [0]*W
for i in range (M):
    h,w = map(lambda x: int(x)-1,input().split())
    m[h][w] = 1
    hlist[h]+=1
    wlist[w]+=1

hmax = 0
hind = []
for i in range(H):
    if hmax < hlist[i]:
        hmax = hlist[i]
        hind = [i]
    elif hmax == hlist[i]:
        hind.append(i)


wmax = 0
wind = []
for i in range(W):
    if wmax < wlist[i]:
        wmax = wlist[i]
        wind = [i]
    elif wmax == wlist[i]:
        wind.append(i)


flag = False
for h in hind:
    for w in wind:
        if m[h][w] == 0:
            print(hmax + wmax)
            flag = True
            break
    if flag:
        break

if not flag:
    print(hmax + wmax - 1)


### FIXED CODE ###

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

hlist = [0]*H
wlist = [0]*W
sets = set()
for i in range (M):
    h,w = map(lambda x: int(x)-1,input().split())
    hlist[h]+=1
    wlist[w]+=1
    sets.add((h,w))

hmax = 0
hind = []
for i in range(H):
    if hmax < hlist[i]:
        hmax = hlist[i]
        hind = [i]
    elif hmax == hlist[i]:
        hind.append(i)


wmax = 0
wind = []
for i in range(W):
    if wmax < wlist[i]:
        wmax = wlist[i]
        wind = [i]
    elif wmax == wlist[i]:
        wind.append(i)


flag = False
for h in hind:
    for w in wind:
        if (h,w) not in sets:
            flag = True
            break
    if flag:
        break

if flag:
    print(hmax + wmax)
else:
    print(hmax + wmax - 1)
import math
import string
N = int(input())
alphabet = list(string.ascii_lowercase)
for i in range(1,11+1):
    if 27**i >= N: break
I = i

ans = ''
n = N
for i in range(I, 0, -1):
    ans += alphabet[n//(26**i)-1]
    n -= (26**i)
if n%26 > 0:
    ans += alphabet[n%26-1]
print(ans)

### FIXED CODE ###

import string
N = int(input())
alphabet = list(string.ascii_lowercase)

n = N
idxs = []
while n > 0:
    n -= 1
    idxs.append(n%26)
    n //= 26

ans = ''
for i in idxs[::-1]:
    ans += alphabet[i]
print(ans)
s = input()
print(s.count("1"))

### FIXED CODE ###

s = input()
print(s.count("1"))
n, m = map(int, input().split())
q = list()
for i in range(m):
    q.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0

for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1, len(q[i]):
            w = q[i][j]
            if s >>(w-1) & 1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        ans += 1
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
q = list()
for i in range(m):
    q.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0

for s in range(2**n):
    judge = True
    for i in range(m):
        cnt = 0
        for j in range(1, len(q[i])):
            w = q[i][j]
            if s >>(w-1) & 1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge = False
    if judge:
        ans += 1
print(ans)
n = int(intput())
i=0
while 2**(i+1)<=n:
  i+=1
print(2**1)

### FIXED CODE ###

n = int(input())
i=0
while 2**(i+1)<=n:
  i+=1
print(2**i)
n = input()
s = list(map(int,input().split()))

nums = [0]*(max(s)+1)

for i in s:
    if i == 0:
        nums[0] += 1
        nums[1] += 1
    elif i == max(s):
        nums[-1] += 1
        nums[-2] += 1
    else:
        nums[i-1] += 1
        nums[i] += 1
        nums[i+1] += 1

print(max(nums))

### FIXED CODE ###

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

MAX = max(s)
nums = [0]*(MAX+1)

if MAX == 0:
    print(n)
    exit()

for i in s:
    if i == 0:
        nums[0] += 1
        nums[1] += 1
    elif i == MAX:
        nums[-1] += 1
        nums[-2] += 1
    else:
        nums[i-1] += 1
        nums[i] += 1
        nums[i+1] += 1

print(max(nums))
X,Y,Z = map(int,input())
print(Z,X,Y)

### FIXED CODE ###

X,Y,Z = map(int,input().split())
print(Z,X,Y)
n=0
i = int(input())
while i != 0:
    n+=1
    print("Case " + str(n) + ":" +i)
    i int(input())


### FIXED CODE ###

n=0
i = int(input())
while i != 0:
    n+=1
    print("Case " + str(n) + ": " +str(i))
    i = int(input())
a=int(input('a'))
b=int(input('b'))

if (a+b)%2 == 0:
    print(a+b)
    print('Even')
else:
    print(a+b)
    print('Odd')

### FIXED CODE ###

a, b = input().split()
a=int(a)
b=int(b)
if (a*b)%2==0:
    print("Even")
else:
    print("Odd")
n = input()
List = [a,i,u,e,o]
if 'n' in List:
    print('vowel')
else:
    print('consonant')

### FIXED CODE ###

n = input()
if n in 'aiueo':
    print('vowel')
else:
    print('consonant')