Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = map(int, input().split())
l = list(map(int, input().split()))
from collections import deque


l = deque(l)

count=0
for i in range(len(l)-1):
    if l[i] >l[i+1]:
        while l[i] >l[i+1]:
            l[i+1]+=1
            count+=1

print(count)

### FIXED CODE ###

N = map(int, input().split())
l = list(map(int, input().split()))
from collections import deque


l = deque(l)

count=0
for i in range(len(l)-1):
    if l[i] >l[i+1]:
        c=l[i] -l[i+1]
        l[i+1]+=c
        count+=c

print(count)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(int(a) for a in input().split())

Acum = [1] * (N+1)
for i in range(N):
    Acum[i+1] = Acum[i] * A[i]

for j in range(K, N):
    now = Acum[j] // Acum[j-K]
    nxt = Acum[j+1] // Acum[j+1-K]
    if now < nxt:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N, K = map(int, input().split())
A = list(int(a) for a in input().split())

for i in range(N-K):
    if A[i] < A[i+K]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n=int(input())
table=[0]*60
for v  in map(int,input().split()):
    for j in range(60):
        if v%2:table[j]+=1
        v//=2
        if v==0:break
ans=0
mod=10**9+7
a=1

for o in table:
    z=(n-o)
    ans=(ans+o*z%mod*a)%mod
    a=a*2%mod
print(ans)

### FIXED CODE ###

n=int(input())
l=[int(c) for c in input().split()]
ans=0
mod=10**9+7
for i in range(60):
  s=sum(a>>i&1 for a in l)
  ans+=s*(n-s)<<i%mod
  ans%=mod
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

h, w = (int(i) for i in input().split())
a = [input() for i in range(h)]

class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.size = [1] * N
        self.N = N

    # xのrootを返す
    def root(self, x):
        if self.par[x] == x:
            return x
        else: 
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    # x, yが同じrootの場合true
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    # x,yのrootが違った場合、併合
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if self.size[rx] < self.size[ry]:
            self.par[rx] = ry
            self.size[ry] += self.size[rx]
        else:
            self.par[ry] = rx
            self.size[rx] += self.size[ry]
            
uf = UnionFind(h*w)

for j in range(h):
    for i in range(w):
        if i != w-1 and a[j][i+1] != a[j][i]:
            uf.unite(w*j+i,w*j+i+1)
        if j != h-1 and a[j+1][i] != a[j][i]:
            uf.unite(w*j+i,w*(j+1)+i)

for v in range(h*w):
    uf.root(v)

l_idx = sorted(list(set(uf.par)))

wc = [0]*len(l_idx)
bc = [0]*len(l_idx)
for j in range(h):
    for i in range(w):
        idx = l_idx.index(uf.par[w*j+i])
        if a[j][i] == ".":
            wc[idx] += 1
        else:
            bc[idx] += 1

res = 0
for i in range(len(l_idx)):
    res += wc[i] * bc[i]
print(res)

### FIXED CODE ###

import sys
input = sys.stdin.readline

h, w = (int(i) for i in input().split())
a = [input() for i in range(h)]

class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.size = [1] * N
        self.N = N

    # xのrootを返す
    def root(self, x):
        if self.par[x] == x:
            return x
        else: 
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    # x, yが同じrootの場合true
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    # x,yのrootが違った場合、併合
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if self.size[rx] < self.size[ry]:
            self.par[rx] = ry
            self.size[ry] += self.size[rx]
        else:
            self.par[ry] = rx
            self.size[rx] += self.size[ry]
            
uf = UnionFind(h*w)

for j in range(h):
    for i in range(w):
        if i != w-1 and a[j][i+1] != a[j][i]:
            uf.unite(w*j+i,w*j+i+1)
        if j != h-1 and a[j+1][i] != a[j][i]:
            uf.unite(w*j+i,w*(j+1)+i)

for v in range(h*w):
    uf.root(v)

wc = [0]*(h*w)
bc = [0]*(h*w)
for j in range(h):
    for i in range(w):
        idx = w*j+i
        if a[j][i] == ".":
            wc[uf.par[idx]] += 1
        else:
            bc[uf.par[idx]] += 1

res = 0
for i in range(h*w):
    res += wc[i] * bc[i]
print(res)
### BUGGY CODE ###

n = int(input())

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

ans = 0

for i in range(n):
	good = True
	for j in range(n):
		if j != i:
			if a[i] % a[j] == 0:
				good = False
				break
	if good:
		ans += 1

print(ans)

### FIXED CODE ###

n = int(input())

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

mx = max(a)

mark = [0 for _ in range(mx+1)]

for i in range(n):
	for x in range(a[i], mx+1, a[i]):
		mark[x] += 1

ans = 0

for i in range(n):
	if mark[a[i]] == 1:
		ans += 1

print(ans)
### BUGGY CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


k=int(input())
#print(prime_factorize(k))
l=factorization(k)
#print(l)
mnum=0
for i in range(len(l)):
    mnum=max(mnum,l[i][0]**l[i][1])
#print(mnum)
if k%2==0:
    print(-1)
    exit()
for i in range(k):
#for i in range(mnum):
    n=int("7"*(i+1))
#    print(n)
    if n%k==0:
        print(i+1)
        exit()
print(-1)


### FIXED CODE ###

k=int(input())
n=7
for i in range(k+1):
    if n%k==0:
        print(i+1)
        exit()
    n=(10*n+7)%k
print(-1)
### BUGGY CODE ###

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

for i in range(p,0,-1):
    if p%(i**n)==0:
        print(i)
        break

### FIXED CODE ###

N, P = map(int, input().split())
ans = 1
 
if N >= 45:
  print(ans)
elif N == 1:
  print(P)
  
 
  
else:
  i = 1
  while(i**N <= P):
    if P % (i**N) == 0:
      ans = i
    i += 1
  print(ans)
### BUGGY CODE ###

def checkCanHalf(ary):
  for item in ary:
    if(item % 2 != 0):
      return False
  return True

n = range(int(input()))
ary = map(int, input().split())
cnt = 0

while checkCanHalf(ary) == True:
  ary = map(lambda x: x / 2, ary)
  cnt += 1

print(cnt)

### FIXED CODE ###

def checkCanHalf(ary):
  for item in ary:
    if(item % 2 != 0):
      return False
  return True

n = range(int(input()))
ary = list(map(int, input().split()))
cnt = 0

while checkCanHalf(ary) == True:
  for i in range(len(ary)):
    ary[i] = ary[i]/2
  cnt += 1

print(cnt)
### BUGGY CODE ###

S=input()
Q=int(input())

a=[input().split() for i in range(Q)]


ans=S
for i in range(Q):
    if a[i][0]=="2":
        if a[i][1]=="1":
            ans=a[i][2]+ans
        else:
            ans=ans+a[i][2]
    else:
        re_ans=""
        for j in range(len(ans)):
            re_ans=re_ans+ans[len(ans)-1-j]
        ans=re_ans
print(ans)

### FIXED CODE ###

S=input()
Q=int(input())

guuki=0
ANS=S
ANS_back=""
ANS_front=""
for i in range(Q):
    A=list(input().split())
    if A[0]=="1":
        guuki+=1
    elif int(A[1])*guuki%2==1 or (A[1]=="2" and guuki%2==0):
        ANS_back+=A[2]
    else:
        ANS_front+=A[2]
if guuki%2==1:
    ANS=ANS[::-1]
    ANS_back,ANS_front=ANS_front,ANS_back
print(ANS_front[::-1]+ANS+ANS_back)
### BUGGY CODE ###

def pri(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i=i+1
    return 1

l=[]
for i in range(2,50100):
    if pri(i):
        l.append(i)
s=len(l)
while 1:
    n=int(raw_input())
    ans=set([])
    if n==0:
        break
    for i in range(s):
        for j in range(i,s):
            if l[i]+l[j]==n:
                ans.add((min(l[i],l[j]),max(l[i],l[j])))
            elif i+j>n:
                break
    print len(ans)

### FIXED CODE ###

def pri(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i=i+1
    return 1

l=[]
for i in range(2,50000):
    if pri(i):
        l.append(i)
s=5133
ans={}
for i in range(5132):
    for j in range(i,5133):
        a,b=l[i],l[j]
        if a+b>50000:
            break
        if ans.has_key(a+b):
            ans[a+b]+=1
        else:
            ans[a+b]=1
while 1:
    n=int(raw_input())
    if n==0:
        break
    print ans[n] if ans.has_key(n) else 0
### BUGGY CODE ###

n,k = map(int, input().split())
As = list(map(int, input().split()))
from itertools import accumulate

def modconb(n,k,mod):
    # テーブルを作る
    fac = [0]*(n+1)
    finv = [0]*(n+1)
    inv = [0]*(n+1)  

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,n+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] %mod
    # 計算
    if n<k: return 0
    if n<0 or k<0: return 0
    return(fac[n]*(finv[k]*finv[n-k]%mod)%mod)
mod = 10**9+7
As.sort()
acc = list(accumulate(As))
As.sort(reverse=True)
acc_r = list(accumulate(As))
ans = 0
for d in range(1,n):
    if d-1 < k-2:
        continue
    if k-2 <= 0:
        c = 1
    else:
        # print(d-1,k-2)
        c = modconb(d-1,k-2,mod)
    ind = min(d-1, n-d-1)
    mn = acc[ind]
    mx = acc_r[ind]
    ans += (mx-mn)*c
    # print(d,c,mn,mx,"d",(mx-mn)*c)
    ans %= mod
print(ans)

### FIXED CODE ###

n,k = map(int, input().split())
As = list(map(int, input().split()))
from itertools import accumulate

def modconb(n,mod):
    # テーブルを作る
    fac = [0]*(n+1)
    finv = [0]*(n+1)
    inv = [0]*(n+1)  

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,n+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] %mod
    # 計算
    if n<k: return 0
    if n<0 or k<0: return 0
    return fac, finv
mod = 10**9+7
fac, finv = modconb(n, mod)
As.sort()
acc = list(accumulate(As))
As.sort(reverse=True)
acc_r = list(accumulate(As))
ans = 0
for d in range(1,n):
    if d-1 < k-2:
        continue
    if k-2 <= 0:
        c = 1
    else:
        c = fac[d-1]*(finv[k-2]*finv[d-1-(k-2)]%mod)%mod
        # c = modconb(d-1,k-2,mod)
    ind = min(d-1, n-d-1)
    mn = acc[ind]
    mx = acc_r[ind]
    ans += (mx-mn)*c
    # print(d,c,mn,mx,"d",(mx-mn)*c)
    ans %= mod
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=lambda x:x[1])
A.sort()

for b,c in BC:
  for i in range(b):
    if A[i] < c:
      A[i] = c
  A.sort()
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=lambda x:x[1])
A.sort()

ans = []
for b,c in BC:
  n = len(ans)
  for i in range(b):
    if n >  N-1: break
    if A[n] < c:
      ans.append(c)
      n += 1
    else: break

print(sum(ans) + sum(A[len(ans):]))
### BUGGY CODE ###

import math
N = int(input())
ans = 0
for i in range(1,10):
    for j in range(1,10):
        c1 = 0
        c2 = 0
        for x in range(1,N+1):
            d = 10 ** int(math.log10(x)) 
        
            if x % 10 == i and x // d == j:
                c1 += 1
            if x % 10 == j and x // d == i:
                c2 += 1
        ans += c1 * c2

print (ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1,10):
    for j in range(1,10):
        c1 = 0
        c2 = 0
        d = 1
        for x in range(1,N+1):
            if x % (d *10) == 0:
                d = d * 10
        
            if x % 10 == i and x // d == j:
                c1 += 1
            if x % 10 == j and x // d == i:
                c2 += 1
        ans += c1 * c2

print (ans)
### BUGGY CODE ###

def solve():
    N, M = map(int, input().split())
    A = []
    B = []
    dp = [float('inf')] * (N + 20000)
    dp[0] = 0
    for _ in range(M):
        a, b = list(map(int, input().split()))
        for i in range(N + 10000):
            if dp[i] == 'inf':
                continue
            dp[i+a] = min(dp[i+a], dp[i] + b)
        
    return min(dp[N:])

print(solve())

### FIXED CODE ###

import numpy as np

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

A = []
B = []
for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

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

dp = np.full((H+1), np.inf)
dp[0] = 0

def solve():
    for i in range(1, H + 1):
        dp[i] = np.amin(dp[np.maximum(i - A , 0)] + B)
    return int(dp[H])

print(solve())
### BUGGY CODE ###

K = int(input())

import math
from functools import reduce

sum = 0

for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            sum += math.gcd(math.gcd(i,j),k)

print(sum)

### FIXED CODE ###

K = int(input())

import math
from functools import reduce

sum = 3*(K-1)*(K-1) + 3*(K-1) + 1

for i in range(2, K + 1):
    for j in range(2, K + 1):
        for k in range(2, K + 1):
            sum += math.gcd(math.gcd(i,j),k)

print(sum)
### BUGGY CODE ###

import collections

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

zen = m
cou = 0

for x in range(n):
    zen.append(m[x]-1)

for x in range(n):
    zen.append(m[x]+1)

a = collections.Counter(zen)

for k in range(n):
    if a.most_common()[0][0] == m[k] or a.most_common()[0][0] == m[k] -1 or a.most_common()[0][0] == m[k] +1:
        cou += 1

print(cou)

### FIXED CODE ###

import collections

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

zen = m
cou = 0

for x in range(n):
    zen.append(m[x]-1)

for x in range(n):
    zen.append(m[x]+1)

a = collections.Counter(zen)

#for k in range(n):
#    if a.most_common()[0][0] == m[k] or a.most_common()[0][0] == m[k] -1 or a.most_common()[0][0] == m[k] +1:
#        cou += 1

print(a.most_common()[0][1])
### BUGGY CODE ###

N = int(input())

power = 1

for i in range(1,N+1):
	power *= i
	
print(power%(1000000007))

### FIXED CODE ###

N = int(input())

power = 1

for i in range(1,N+1):
	power *= i
	power %= 1000000007
	
print(power)
### BUGGY CODE ###

from math import gcd
n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            if i==j and j==k: ans+=i
            else:
                tmp = gcd(k, gcd(i,j))
                ans+=tmp
print(ans)

### FIXED CODE ###

from math import gcd
n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            if i==j and j==k: ans+=i
            else:
                tmp = gcd(k, gcd(i,j))
                ans+=tmp
print(ans)
### BUGGY CODE ###

N,M,R=map(int,input().split())
r=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
d=[[float("inf")]*N for i in range(N)]

for a,b,c in A:
  d[a-1][b-1]=c
  d[b-1][a-1]=c 
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
      
import itertools 
ans=10**5*8
for i in itertools.permutations(range(R),R):
  D=0
  for j in range(R-1):
    D+=d[r[i[j]]-1][r[i[j+1]]-1]
  ans=min(D,ans)
print(ans)

### FIXED CODE ###

from subprocess import call
call(('pypy3','-c',"""N,M,R=map(int,input().split())
r=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
d=[[float("inf")]*N for i in range(N)]

for a,b,c in A:
  d[a-1][b-1]=c
  d[b-1][a-1]=c 
  
for k in range(N):
  for i in range(N):
    for j in range(N):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
      
import itertools 
ans=1000000000
for i in itertools.permutations(range(R),R):
  D=0
  for j in range(R-1):
    D+=d[r[i[j]]-1][r[i[j+1]]-1]
  ans=min(D,ans)
print(ans)
"""))
### BUGGY CODE ###

N = int(input())
nums = [int(input()) for i in range(N)]
ans = []

for num in nums:
    if ans.count(num) == 0:
        ans.append(num)
    else:
        ans.remove(num)

print(len(ans))

### FIXED CODE ###

N = int(input())
nums = [int(input()) for i in range(N)]
idxs = set(nums)
ans = {idxs.pop() : 0 for i in range(len(idxs))}
count = 0

for num in nums:
    ans[num] += 1

for i in ans.keys():
    ans[i] = (ans[i] % 2)

print(sum(ans.values()))
### BUGGY CODE ###

from itertools import permutations as perm
import numpy as np


def main():
    n = int(input())
    xys = [list(map(int, input().split())) for _ in range(n)]

    orders = np.array(list(perm([xys[i] for i in range(n)], n)))
    ans = 0
    order_num = len(orders)

    for order in orders:
        temp = 0
        for i in range(n-1):
            temp += np.linalg.norm(order[i]-order[i+1])
        ans += temp
    print(ans/order_num)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from itertools import permutations as perm


def euclidean_distance(list1, list2):
    x_norm = (list1[0] - list2[0]) ** 2
    y_norm = (list1[1] - list2[1]) ** 2
    return (x_norm + y_norm) ** 0.5


def main():
    n = int(input())
    xys = [list(map(int, input().split())) for _ in range(n)]

    orders = list(perm([xys[i] for i in range(n)], n))
    order_num = len(orders)
    ans = 0
    for order in orders:
        for i in range(n-1):
            ans += euclidean_distance(order[i], order[i+1])

    print(ans/order_num)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

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


def make_divisor_list(num, N):

    if num < 1:
        return 0
    elif num == 1:
        return 1
    else:
        max_num = 1
        for i in range(2, num // N + 1):
            if num % i == 0:
                # 割り切れる=約数
                if num / i >= N:
                    max_num = i
        return max_num

print(make_divisor_list(M, N))

### FIXED CODE ###

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

def make_divisor_list(num, N):

    if num < 1:
        return 0
    elif num == 1:
        return 1
    else:
        max_num = 1
        for i in reversed(range(2, num // N + 1)):
            if num % i == 0:
                # 割り切れる=約数
                if num / i >= N:
                    max_num = i
                    break
                #else:
                #    break
        return max_num

print(make_divisor_list(M, N))
### BUGGY CODE ###

from math import gcd, sqrt


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            if i != 1:
                divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    # divisors.sort()
    return divisors


def main():
    N = input()
    A = list(map(int, input().split()))

    s_tmp = A[0]
    p_flag = True
    p_dic = []
    for a in A:
        s_tmp = gcd(s_tmp, a)
        if p_flag:
            tmp = Calc_Divisors(a)
            for t in tmp:
                if t not in p_dic:
                    p_dic.append(t)
                else:
                    p_flag = False
                    continue

    if p_flag:
        print('pairwise coprime')
    elif s_tmp == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import gcd, sqrt


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    N = input()
    A = list(map(int, input().split()))

    s_tmp = A[0]
    p_flag = True
    p_dic = [0] * (10**6+1)
    for a in A:
        s_tmp = gcd(s_tmp, a)
        if p_flag:
            tmp = list(set(prime_factorize(a)))
            for t in tmp:
                if p_dic[t] == 0:
                    p_dic[t] = 1
                else:
                    p_flag = False
                    continue

    if p_flag:
        print('pairwise coprime')
    elif s_tmp == 1:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == "__main__":
    main()
### BUGGY CODE ###

# Atcoder forces me to use fractions.gcd instead of math.gec because the contest accepts only python 3.4

import fractions
from functools import reduce


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


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

if len(A) == 1:
    ans = A[0]
else:
    ans = 1
    for i in range(len(A)):
        ans = max(ans, gcd_list(A[:i] + A[i + 1:]))

print(ans)


### FIXED CODE ###

# Atcoder forces me to use fractions.gcd instead of math.gec because the contest accepts only python 3.4

import fractions
from functools import reduce


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N = int(input())
A = list(map(int, input().split()))
A_set = list(set(A))
A_lib = {}
for a in A:
    if a in A_lib:
        A_lib[a] += 1
    else:
        A_lib[a] = 1

if len(A_set) == 1:
    ans = A_set[0]
else:
    ans = gcd_list(A_set)
    for i in range(len(A_set)):
        if A_lib[A_set[i]] == 1:
            ans = max(ans, gcd_list(A_set[:i] + A_set[i + 1:]))

print(ans)
### BUGGY CODE ###

(h,w,m),*e=[[*map(int,i.split())]for i in open(0)];a,b=[0]*h,[0]*w
for y,x in e:a[y-1]+=1;b[x-1]+=1
print(max(a)+max(b)-(a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==max(a)+max(b)for y,x in e)<=0))

### FIXED CODE ###

(h,w,m),*e=[[*map(int,i.split())]for i in open(0)]
a,b=[0]*h,[0]*w
for y,x in e:
    a[y-1]+=1
    b[x-1]+=1
ans=max(a)+max(b)
c=a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e)
print(ans-(c<=0))
### BUGGY CODE ###

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

A = [[0] * 2 for i in range(M)]

for i in range(M):
    A[i][0], A[i][1] = input().split()


AC = [0] * M
WA = [0] * M

for j in range(M)[::-1]:
    if A[j][1] == 'AC' and (A[j][0] in AC) is False:
        AC[j] = A[j][0]
    elif A[j][1] == 'WA' and (A[j][0] in AC) is True:
        WA[j] = A[j][0]

print(len(AC) - AC.count(0), len(WA) - WA.count(0))


### FIXED CODE ###

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

submit = [input().split() for i in range(M)]
ans = [[0, 0] for i in range(N)]

for i in range(M):
    tmp = int(submit[i][0]) - 1
    if submit[i][1] == 'AC' and ans[tmp][0] == 0:
        ans[tmp][0] += 1
    elif submit[i][1] == 'WA' and ans[tmp][0] == 0:
        ans[tmp][1] += 1

print(sum(ans[i][0] for i in range(N)), sum(ans[i][1] for i in range(N) if ans[i][0] == 1))
### BUGGY CODE ###

import random
import time
import copy
start=time.time()
d=int(input())
c=list(map(int, input().split()))
s=[]
solution=[]
last=[0]*26
sco=0
for i in range(d):
  s.append(list(map(int, input().split())))
for day in range(1,d+1):
  man=[]
  for i in range(26):
    man.append(s[day-1][i]+last[i]*c[i])
  con=man.index(max(man))
  sco+=s[day-1][con]
  last[con]=day
  for (i,j) in zip(last,c):
    sco-=i*j
  solution.append(con)
while time.time()-start<1.9:
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(10)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,c):
      sc-=i*j
  if sc>sco:
    solution=copy.deepcopy(sol)
    sco=sc
for i in solution:
  print(i+1)

### FIXED CODE ###

d=int(input())
c=list(map(int, input().split()))
s=[]
for i in range(d):
  s.append(list(map(int, input().split())))
for i in s:
  print(i.index(max(i))+1)
### BUGGY CODE ###

from collections import deque
n, m = map(int, input().split())
q = deque()
keys = [0] * n
dic = {i: [] for i in range(n)}
for _ in range(m):
    a, b = map(int, input().split())
    dic[a - 1].append(b - 1)
    dic[b - 1].append(a - 1)

for i in dic[0]:
    q.append(i)
    keys[i] = 1
while len(q) > 0:
    next = q.popleft()
    for i in dic[next]:
        if keys[i]:
            continue
        if i not in q:
            q.append(i)
            keys[i] = next + 1
if 0 in keys[1:]:
    print('No')
else:
    print('Yes')
    for i in keys[1:]:
        print(i)

### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
q = deque()
t = {i: set() for i in range(1, n + 1)}
v = [-1] * n

for _ in range(m):
    a, b = map(int, input().split())
    t[a].add(b)
    t[b].add(a)
q.append(1)
v[0] = 1
while q:
    next = q.popleft()
    for i in t[next]:
        if v[i - 1] == -1:
            q.append(i)
            v[i - 1] = next
print('Yes')
print(*v[1:], sep='\n')