Harryxun/stf_run huggingface dataset:
H, W, M = map(int, input().split())
bombs = []
for i in range(H):
    bombs.append([False] * W)
rows = []
for i in range(H):
    rows.append([i, 0])
cols = []
for i in range(W):
    cols.append([i, 0])
for i in range(M):
    y, x = map(lambda x: x - 1, map(int, input().split()))
    bombs[y][x] = True
    rows[y][1] += 1
    cols[x][1] += 1


rows = sorted(rows, key=lambda x: x[1], reverse=True)
cols = sorted(cols, key=lambda x: x[1], reverse=True)
answer = 0
for row in rows:
    a = cols[0][1] + row[1] - (1 if bombs[row[0]][cols[0][0]] else 0)
    if a > answer:
        answer = a
for col in cols:
    a = rows[0][1] + col[1] - (1 if bombs[rows[0][0]][col[0]] else 0)
    if a > answer:
        answer = a
print(answer)

### FIXED CODE ###

H, W, M = map(int, input().split())
bombs = {}
rows = []
cols = []
for i in range(H):
    rows.append([i, 0])
for i in range(W):
    cols.append([i, 0])
for i in range(M):
    y, x = map(lambda x: x - 1, map(int, input().split()))
    bombs[(y,x)] = True
    rows[y][1] += 1
    cols[x][1] += 1


rows = sorted(rows, key=lambda x: x[1], reverse=True)
cols = sorted(cols, key=lambda x: x[1], reverse=True)
answer = 0
for row in rows:
    a = cols[0][1] + row[1] - (1 if (row[0], cols[0][0]) in bombs else 0)
    if a > answer:
        answer = a
for col in cols:
    a = rows[0][1] + col[1] - (1 if (rows[0][0], col[0]) in bombs else 0)
    if a > answer:
        answer = a
print(answer)
N=input()
if N % 2 ==0:
  print(N/2)
else:
  print(N//2+1)

### FIXED CODE ###

N=int(input())
if N % 2 ==0:
  print(N//2)
else:
  print(N//2+1)
c = a*b%2

if c = 0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

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

c = a*b%2

if c == 0:
    print("Even")
else:
    print("Odd")
a, b, h = [int(input()) for i in range(3)]
print(int((a+b)*h/2)

### FIXED CODE ###

a, b, h = [int(input()) for i in range(3)]
print(int((a+b)*h/2))
S = input()

DAY = ["SUN","MON","TUE","WED","THU","FRY","SAT"]

print(7-DAY.index(S))

### FIXED CODE ###

S = input()

DAY = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

print(7-DAY.index(S))
s = input()
while True:
    s.pop()
    if len(s)%2==0 and s[:len(s)//2]==s[len(s)//2:]:
        print(len(s))
        exit()

### FIXED CODE ###

s = input()
l = len(s)
h = l//2
if l%2==0:
    for i in range(1,h):
        if s[0:h-i] == s[h-i:-2*i]:
            print(len(s[:-2*i]))
            break
else:
    for i in range(1,h):
        if s[0:h-i+1] == s[h-i+1:-2*i+1]:
            print(len(s[:-2*i+1]))
            break
print((1000-input()%1000)%1000)

### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    if N % 1000 == 0:
        print(0)
    else:
        print(1000 - N%1000)

if __name__ == "__main__":
    main()
import numpy as np

N, M, K = map(int, input().split())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

A = np.array(A)
B = np.array(B)

A0 = np.cumsum(A)
B0 = np.cumsum(B)

A1 = np.zeros((N,2))
A1[:,0] = A0
A1[:,1] = np.arange(1,N+1)

B1 = np.zeros((M,2))
B1[:,0] = B0
B1[:,1] = np.arange(1,M+1)

print(A1)

C1 = np.zeros((N*M,2))
for i in range(N):
    for j in range(M):
        C1[M*i+j,:] = A1[i,:] + B1[j,:]
C2 = np.array([C[1] for C in C1 if C[0] <= K])

if len(C2):
    print(int(C2.max()))
else:
    print(0)

### FIXED CODE ###

import numpy as np

N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

A = np.array(A).cumsum()
B = np.array(B).cumsum()

ans = 0
j = M
for i in range(N+1):
    if A[i] > K:
        break
    while B[j] > K - A[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a> b:
  num1 = b
else:
  num1 = a
if c > d:
  num2 = d
else:
  num2 = c
print(nu1+num2)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a> b:
  num1 = b
else:
  num1 = a
if c > d:
  num2 = d
else:
  num2 = c
print(num1+num2)
#include<iostream>
#include <bits/stdc++.h> 
using namespace std; 
  
int countValues(int n) 
{ 
    int unset_bits=0; 
    while (n) 
    { 
        if ((n & 1) == 0) 
            unset_bits++; 
        n=n>>1; 
    } 
  
    return 1 << unset_bits; 
} 
  
int main() 
{ 
    int n;
  	cin >> n;
    cout << countValues(n) << endl; 
    return 0; 
} 


### FIXED CODE ###

p, q, r = map(int, input().split())

a = p + q
b = q + r
c = r + p
print(min(a, b, c))
S = int(input())
n = len(S)
a = "10" * n + "1" * (n % 2)
b = "01" * n + "0" * (n % 2)

print(min(bin(int(s,2) ^ int(a, 2) , bin(int(s, 2) ^ int(b, 2)))))

### FIXED CODE ###

s = input()
n = len(s)
a = "10" * (n // 2) + "1" * (n % 2)
b = "01" * (n // 2) + "0" * (n % 2)

print(min(bin(int(s,2) ^ int(a, 2)).count("1") , bin(int(s, 2) ^ int(b, 2)).count("1")))
import sys
import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

n = readInt()
aa = [readInt() for _ in range(n)]

memo = {}
def dfs(a, b, c, i):
    if i == len(aa):
        return 1 if c < a + b else 0
    if (a,b,c,i) in memo:
        return memo[(a,b,c,i)]

    ret = 0
    v0 = sorted([a + aa[i], b, c])
    ret = (ret + dfs(*v0, i + 1)) % 998244353

    v1 = sorted([a, b + aa[i], c])
    ret = (ret + dfs(*v1, i + 1)) % 998244353

    v2 = sorted([a, b, c + aa[i]])
    ret = (ret + dfs(*v2, i + 1)) % 998244353


    memo[(a,b,c,i)] = ret
    return ret

ret = dfs(0, 0, 0, 0)
print(ret)

### FIXED CODE ###

import sys

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(" ")]

total = 0
ret = 1
n = readInt()
aa = []
for i in range(n):
    v = readInt()
    aa.append(v)
    total += v
    ret *= 3


L = (n * max(aa) + 1)
memo = [-1] * ((n+1) * L * 2)
def dfs(i, c):
    key = (i * L * 2) + 2 * c
    if 0 <= memo[key]:
        return memo[key: key+2]

    if i == n:
        memo[key + 0] = 3 if total <= (2 * c) else 0
        memo[key + 1] = 3 if total == (2 * c) else 0
        return memo[key: key + 2]

    v0 = dfs(i + 1, c)
    v1 = dfs(i + 1, c + aa[i])

    memo[key + 0] = (2 * v0[0] + v1[0]) % 998244353
    memo[key + 1] = (v0[1] + v1[1]) % 998244353
    return memo[key: key + 2]

a, b = dfs(0, 0)
ret = (ret - a + b) % 998244353
print(ret)
A,B = map(int,input())

print(6 - A - B)


### FIXED CODE ###

A = int(input())
B = int(input())

print(6-A-B)
s, t = map(input().split())
a, b = map(int, input().split())
t = input()
if s == t:
  print(str(a-1) + " " + str(b))
else:
  print(str(a) + " " + str(b-1))

### FIXED CODE ###

s = input().split()
a, b = map(int, input().split())
t = input()
if s[0] == t:
  print(str(a-1) + " " + str(b))
else:
  print(str(a) + " " + str(b-1))
n = int(input())
x = list(map(int,input().split()))
anslist = []
for i in range(1,max(x)):
    ans = 0
    for j in range(len(x)):
        ans += (i-x[j])**2
    anslist.append(ans)
print(min(anslist))


### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(min(x),max(x)):
    num = 0
    for j in range(len(x)):
        num += (i-x[j])**2
    if ans == 0:
        ans = num
    elif num < ans:
        ans = num
print(ans)
Y_DIR[-1,0,1]
X_DIR[-1,0,1]
def count_bomb(y,x):
  cnt=0
  for yd in Y_DIR:
    yy=y+yd
    if not (0<=yy<h):
      continue
    for xd in X_DIR:
      xx=x+xd
      if not (0<=xx<w):
        continue
      if s[yy][xx]=="#":
        cnt+=1
  return cnt

h,w=map(int,input().split())
s=[]
for i in range(h):
  s.append(input())
for y in range(h):
  for x in range(w)
    if s[y][x] == ".":
      s[y][x]=str(count_bomb(y,x))

print("\n".join(s)) 
      


### FIXED CODE ###

Y_DIR=[-1,0,1]
X_DIR=[-1,0,1]
def count_bomb(y,x):
  cnt=0
  for yd in Y_DIR:
    yy=y+yd
    if not (0<=yy<h):
      continue
    for xd in X_DIR:
      xx=x+xd
      if not (0<=xx<w):
        continue
      if s[yy][xx]=="#":
        cnt+=1
  return cnt

h,w=map(int,input().split())
s=[]
for i in range(h):
  s.append(input())
  
ans=["" for _ in range(h)]
for y in range(h):
  for x in range(w):
    if s[y][x] == ".":
      c=count_bomb(y,x)
      ans[y]+=str(c)
    else:
      ans[y]+=s[y][x]

print("\n".join(ans))
import sys
from collections import deque

readline = sys.stdin.readline

x,y,a,b,c=map(int,readline().split())
lst=[]
red=deque(sorted(int(i) for i in readline().split())[-x:])
green=deque(sorted(int(i) for i in readline().split())[-y:])
nc=sorted([int(i) for i in readline().split()], reverse=1)

res=0
for i in nc:
  if i>red[0]:
    red.popleft()
    res+=i
  elif i > green[0]:
    green.popleft()
    res+=i
res+=sum(red)+sum(green)
print(res)

### FIXED CODE ###

import sys
from collections import deque
readline = sys.stdin.readline

def main():
  x,y,a,b,c=map(int,readline().split())

  red=[int(i) for i in readline().split()]
  green=[int(i) for i in readline().split()]
  nc=sorted([int(i) for i in readline().split()], reverse=1)
  if a<x:
    red+=nc[:(x-a)]
    nc=nc[(x-a):]
  if b<y:
    green+=nc[:(y-b)]
    nc=nc[(y-b):]
  red=deque(sorted(red)[-x:])
  green=deque(sorted(green)[-y:])
  res=0
  
  def ppl(lst,i,t):
    if i>t:
      lst.popleft()
      return i
    else:
      return 0
    
  for i in nc:
    if (not red) and (not green):
      break
    if not red:
      tg=green[0]
      res+=ppl(green,i,tg)
    elif not green:
      tr=red[0]
      res+=ppl(red,i,tr)
    else:
      tr=red[0]
      tg=green[0]
      if tr<tg:
        res+=ppl(red,i,tr)
      else:
        res+=ppl(green,i,tg)
    
  print(res+sum(red)+sum(green))

main()
N=int(input())
A=N//100
M=N%100
 
B=M//10
C=M%10
 
if 7 in [A,B,C]:
    print(Yes)
else:
    print(No)

### FIXED CODE ###

N=int(input())
A=N//100
M=N%100
 
B=M//10
C=M%10
 
if 7 in [A,B,C]:
    print('Yes')
else:
    print('No')
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N - 1)]
px = [list(map(int, input().split())) for i in range(Q)]

root = [[] for i in range(N + 1)]
result = [0 for i in range(N + 1)]

for i in range(N - 1):
    a = ab[i][0]
    b = ab[i][1]
    root[a].append(b)
    root[b].append(a)

for i in range(Q):
    p = px[i][0]
    x = px[i][1]
    result[p] = result[p] + x


def dfs(now, prev):
    if len(root[now]) == 0:
        return
    else:
        for i in range(len(root[now])):
            next_point = root[now][i]
            if next_point == prev:
                continue
            else:
                result[next_point] = result[next_point] + result[now]
                dfs(next_point, now)


dfs(1, -1)
print(*result[1:])

### FIXED CODE ###

N, Q = map(int,input().split()) # 複数の数字を変数に格納
List_ab = [list(map(int,input().split())) for i in range(N-1)] # [[1,2],[3,4],[5,6]]
List_px = [list(map(int,input().split())) for i in range(Q)] # [[1,2],[3,4],[5,6]]

count_list = [0]*N

List_ab.sort()

for i in range(Q):
    count_list[List_px[i][0]-1] += List_px[i][1]
        
for i in range(N-1):
    count_list[List_ab[i][1]-1] += count_list[List_ab[i][0]-1]
    
print(*count_list)
# -*- coding: utf-8 -*-

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

AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]

for _ in range(M):
    p,s = input().split()
    p = int(p)
    if AC[p]:
        continue
    if s=='AC':
        AC[p] = True
    else:
        WA[p] += 1

print(sum(AC), sum(WA))

### FIXED CODE ###

# -*- coding: utf-8 -*-

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

AC = [False for _ in range(N)]
WA = [0 for _ in range(N)]
total_WA = 0

for _ in range(M):
    p,s = input().split()
    p = int(p)-1
    if AC[p]:
        continue
    if s=='AC':
        AC[p] = True
        total_WA += WA[p]
    else:
        WA[p] += 1

print(sum(AC), total_WA)
n=int(input())
listv=[int(x) for x in input().split()]
listc=[int(y) for y in input().split()]
values=[x - y for (x, y) in zip(listv, listc)]
ans = 0
for i in values:
  if i>0:
    ans+=i
print(ans)

### FIXED CODE ###

a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""
A=[]
fp =0
bp =0
cmd = raw_input()
n=int(raw_input())
while n: 
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif cmd[6] == 'F':
        A.pop()
        fp -=1
    elif cmd[6] == 'L':
        bp +=1
    n -=1
 
for e in A[bp:fp+1][::-1]:
    print int(e),

### FIXED CODE ###


A=[]
fp =0
bp =0

n=int(raw_input())
while n:
    s = raw_input()

    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1

for e in A[bp:fp+1][::-1]:
    print int(e),
n=int(input())
s=list(input())
t=list(input())  
sum=""
for i in range(n):
  sum= sum+s[i]+t[i]
print(sum)

### FIXED CODE ###

N=int(input())
S,T=input().split()
sum=""
for i in range(N):
  sum+=S[i]
  sum+=T[i]
print(sum)
# coding: utf-8
# Your code here!

words= list(input())
target = list(input())
for i in reversed(range(len(words)-len(target)+1)):
    # print(words[i])
    flag = True
    for j in range(len(target)):
        if not(words[i+j] == target[j] or words[i+j] == '?'):
            flag = False
            break
    if flag is True:
        if i==0:
            words[len(words)-len(target)+1:]=target
        else:
            words[i:i+len(target)] = target
        for k,word in enumerate(words):
            if word == '?':
                words[k]='a'
        break

if flag is True:
    print(''.join(words))
else:
    print("UNRESTORABLE")


### FIXED CODE ###

# coding: utf-8
# Your code here!

words= list(input())
target = list(input())
i=len(words)-len(target)
flag=False
while(0<=i):
    flag = True
    for j in range(len(target)):
        if not(words[i+j] == target[j] or words[i+j] == '?'):
            flag = False
            break
    if flag is True:
        words[i:i+len(target)] = target
        for k,word in enumerate(words):
            if word == '?':
                words[k]='a'
        break
    i-=1

if flag is True:
    print(''.join(words))
else:
    print("UNRESTORABLE")
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W, N, *A = map(int, read().split())

    C = [[0] * W for _ in range(H)]
    vec = [i for i, a in enumerate(A, 1) for _ in range(a)]

    for i in range(H):
        for j in range(W):
            color = vec[i * H + j]
            if i % 2 == 0:
                C[i][j] = color
            else:
                C[i][W - j - 1] = color

    for row in C:
        print(*row)

    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W, N, *A = map(int, read().split())

    C = [[0] * W for _ in range(H)]
    vec = [i for i, a in enumerate(A, 1) for _ in range(a)]

    for i in range(H):
        for j in range(W):
            color = vec[i * W + j]
            if i % 2 == 0:
                C[i][j] = color
            else:
                C[i][W - j - 1] = color

    for row in C:
        print(*row)

    return


if __name__ == '__main__':
    main()
N, M = map(int,input().split())
x = []
y = []
for i in range(M):
    x1,y1=[i for i in input().split()]
    x.append(int(x1))
    y.append(y1)

if not any(x):
  print('{} {}'.format(0, 0))
  exit()


countWC = 0
countAC = 0
index = 0

for i in range(N):
  while y[index] == 'WA':
    countWC += 1
    index += 1   
  if index > 0:
    if x[index] == x[index - 1]:
      if y[index] == 'AC' and y[index - 1] == 'AC':
        continue
      if y[index] == 'WA' and y[index - 1] == 'AC':
        continue
  countAC += 1 
  index += 1

	
print('{} {}'.format(countAC, countWC))

### FIXED CODE ###

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

ac = [0] *N
pena = [0] *N

for _ in range(M):
    P, S = map(str, input().split())
    P = int(P) - 1
    if ac[P]: continue
    if S == 'AC':
        ac[P] = 1
    else:
        pena[P] += 1

AC = 0
PENA = 0

for i in range(N):
    AC += ac[i]
    if ac[i]:
        PENA += pena[i]

print('{} {}'.format(AC, PENA))
1 S = input()
2 print(min(abs(int(S[i:i+3]) - 753) for i in range(len(S) - 2)))


### FIXED CODE ###

S = input()
print(min(abs(int(S[i:i+3]) - 753) for i in range(len(S) - 2)))
import sys
sys.setrecursionlimit(10**6)

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

if k==0:
    print(max(a))
    sys.exit()

def rf(mm):
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(200):
    if rf(m)>(n+k):
        lm=m
        m=int((um+lm)//2)
    elif rf(m)<(n+k):
        um=m
        m=int((um+lm)//2)
    else:
        um=m-1
        m=int((um+lm)//2)
    if rf(m)==(n+k) and um-lm<5:
        break

for mi in range(m+5,max(1,m-10),-1):
    if rf(mi)==(n+k) and rf(mi-1)>(n+k):
        break

print(mi)


### FIXED CODE ###

import sys

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

if k==0:
    print(max(a))
    sys.exit()

def rf(mm):
    if mm==0:
        mm=1
    icnt=0
    for i in range(n):
        icnt+=(a[i]-1)//mm+1
    return icnt

asum=sum(a)
m=asum//(n+k)
um=asum
lm=1
for ii in range(60):
    if m==1:
        break
    if rf(m)<=(n+k) and rf(m-1)>(n+k):
        break
    if um-lm<5:
        break
    if rf(m)>(n+k):
        lm=m
        m=(um+lm)//2-1
    elif rf(m)<(n+k):
        um=m
        m=(um+lm)//2-1
    else:
        um=m-1
        m=(um+lm)//2-1
#    if rf(m)==(n+k) and um-lm<5:

if um<1:
    print(1)
    sys.exit()
    
for mi in range(um,max(0,lm-1),-1):
    if rf(mi)<=(n+k) and rf(mi-1)>(n+k):
        break

print(mi)
a=input()
s=input()

if a>=3200:
    print(s)

else:
    print('red')

### FIXED CODE ###

a=int(input())
s=input()

if a>=3200:
    print(s)

else:
    print('red')
a,b,c=map(int,input().split())

ans="No"
for i in range(1,b+1):
  for j in range(1,a+1):
    if a*i=b*j+c:
      ans="Yes"
      break
      
print(ans)

### FIXED CODE ###

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

ans="NO"
for i in range(0,b+1):
  for j in range(0,a+1):
    if a*i == b*j+c:
      ans="YES"
      break
      
print(ans)
# -*- coding: utf-8 -*-

import math

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

ans = 0

Cans = math.floor(B/C) - math.ceil(A/C) + 1
Dans = math.floor(B/D) - math.ceil(A/D) + 1

CD = C * D / math.gcd(C,D)
CDans = math.floor(B/CD) - math.ceil(A/CD) + 1

ans = (B-A+1) - (Cans + Dans - CDans)

print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-

from fractions import gcd
from math import ceil,floor

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

Cans = B//C - (A-1)//C
Dans = B//D - (A-1)//D

CD = C * D // gcd(C,D)
CDans = B//CD - (A-1)//CD

ans = (B-A+1) - (Cans + Dans - CDans)

print(ans)
N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))

l = []

for i in range(N):
    total_li = sum(candies_i[:+=1])
    total_lj = sum(candies_j[+=1:])
    total = total_li + total_lj
    l.append(total)

print(max(l))


### FIXED CODE ###

N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))

l = []

for i in range(N):
    total_li = sum(candies_i[:i+1])
    total_lj = sum(candies_j[i:])
    total = total_li + total_lj
    l.append(total)

print(max(l))
a=int(input())
b=int(input())
c=int(input())
n=6000
ans=0
for i in range(1000):
  for j in range(1000):
    if 500*i+100*j>n:
      break
    else:
      (n-500*i-100*j)%50==0:
        ans+=1
  if 500*i>n:
    break
print(ans)

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
n=int(input())
ans=0
for i in range(a+1):
  for j in range(b+1):
    if 500*i+100*j>n:
      break
    else:
      if(n-500*i-100*j)%50==0 and (n-500*i-100*j)//50<=c:
        ans+=1
  if 500*i>n:
    break
print(ans)
N, M = map(int,input().split())

return(N*(N-1)//2 + M*(M-1)//2)

### FIXED CODE ###

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

print(N*(N-1)//2 + M*(M-1)//2)
n=int(input())
ans=""
for i in range(1, n+1)
  if i%3==0 or i%10==3:
    ans += " "+str(i)
print(ans)


### FIXED CODE ###

n=int(input())
d=[]
for i in range(1,n+1):
    if i%3==0 or "3" in str(i):
        d.append(i)
print(" ",end="")
print(*d)
h,w=map(int,input().split())
list1=[[0 for i in range(h)] for j in range(w)]
for i in range(h):
    list1[i]=list(map(str,input().split()))
print('#'*(w+2))
for i in range(h):
    print('#'+str(''.join(list1[i]))+'#')
print('#'*(w+2))

### FIXED CODE ###

h,w=map(int,input().split())
list1=[[0 for i in range(w)]for j in range(h)]
for i in range(h):
    list1[i]=list(map(str,input().split()))
print('#'*(w+2))
for i in range(h):
    print('#'+str(''.join(list1[i]))+'#')
print('#'*(w+2))
s = str(input())

if s == "ABC":
    print("ARC")
else:
    print("ABC)

### FIXED CODE ###

s = str(input())

if s == "ABC":
    print("ARC")
else:
    print("ABC")
from functools import reduce
import copy
import math

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


gcds = []

for i in range(N):
    for x in set(integers):
        tmp_integers = copy.copy(integers)
        tmp_integers[i] = x
        gcds.append(reduce(math.gcd, tmp_integers))
print(max(gcds))


### FIXED CODE ###

# coding: utf-8

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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    return gcd(b, a%b)

L = [0]
R = [0]

for i in range(n):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[n-1-i]))
R.reverse()

result = []

for i in range(n):
    result.append(gcd(L[i], R[i+1])) 

print(max(result))
n=int(input())
l=list(map(int,input().split(" ")))
ans=0

while i <len(l):
    if l[i]%2!=0:
        break
    else:
        l[i]=int(l[i]/2)
        i+=1
    ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split(" ")))
ans=0
j=0
while j==0:
    i=0
    while i <len(l):
        if l[i]%2!=0:
            j=1
        else:
            l[i]=int(l[i]/2)
        i+=1
    ans+=1
print(ans-1)
from collections import Counter

n = int(input())
V = [int(n) for n in input().split()]

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else vp[0][1] == vn[0][1]:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vn[0][1]
            else:
                gp = vp[0][1]
                gn = vn[1][1]
 
    ans = n - gp - gn
print(ans)

### FIXED CODE ###

from collections import Counter

n = int(input())
V = [int(n) for n in input().split()]

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vn[0][1]
            else:
                gp = vp[0][1]
                gn = vn[1][1]
 
    ans = n - gp - gn
print(ans)