Problem:
 Score : 200 points    Problem Statement Takahashi has N blue cards and M red cards.
A string is written on each card. The string written on the i -th blue card is s_i , and the string written on the i -th red card is t_i .  Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen.  Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces atcoder , he will not earn money even if there are blue cards with atcoderr , atcode , btcoder , and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.)  At most how much can he earn on balance?  Note that the same string may be written on multiple cards.      Constraints  N and M are integers.  1 \leq N, M \leq 100  s_1, s_2, ..., s_N, t_1, t_2, ..., t_M are all strings of lengths between 1 and 10 (inclusive) consisting of lowercase English letters.         Input Input is given from Standard Input in the following format:  N  s_1  s_2  :  s_N  M  t_1  t_2  :  t_M       Output If Takahashi can earn at most X yen on balance, print X .        Sample Input 1 3
apple
orange
apple
1
grape      Sample Output 1 2  He can earn 2 yen by announcing apple .       Sample Input 2 3
apple
orange
apple
5
apple
apple
apple
apple
apple      Sample Output 2 1  If he announces apple , he will lose 3 yen. If he announces orange , he can earn 1 yen.       Sample Input 3 1
voldemort
10
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort
voldemort      Sample Output 3 0  If he announces voldemort , he will lose 9 yen. If he announces orange , for example, he can avoid losing a yen.       Sample Input 4 6
red
red
blue
yellow
yellow
red
5
red
red
yellow
green
blue      Sample Output 4 1

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
li=list(set(s))
print(max(0,max(s.count(li[i])-t.count(li[i]) for i in range(len(li)))))

Solution (Python):
from collections import Counter
N=int(input())
S=Counter([input() for i in range(N)])
M=int(input())
T=Counter([input() for i in range(M)])
ans=0
for key in S.keys():
    ans = max(S.get(key)-T.get(key,0),ans)
print(ans)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
money=0
for word in s:
    money = max(money,s.count(word)-t.count(word))
print(money)

Solution (Python):
import sys
N = int(sys.stdin.readline())
S = [sys.stdin.readline() for i in range(N)]
M = int(sys.stdin.readline())
T = [sys.stdin.readline() for j in range(M)]
ans = 0
for s in S:
  money = S.count(s) + T.count(s) * -1
  ans = max(ans, money)
print(ans)

Solution (Python):

from collections import Counter
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, s: "List[str]", M: int, t: "List[str]"):
    ctr = Counter(s)
    ctr.subtract(t)
    ((_key, cnt),) = ctr.most_common(1)
    print(max(0, cnt))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    s = [next(tokens) for _ in range(N)]  
    M = int(next(tokens))  
    t = [next(tokens) for _ in range(M)]  
    solve(N, s, M, t)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
N = int(sys.stdin.readline())
S = [sys.stdin.readline() for i in range(N)]
M = int(sys.stdin.readline())
T = [sys.stdin.readline() for j in range(M)]
ans = 0
for s in S:
  money = S.count(s) + T.count(s) * -1
  ans = max(ans, money)
print(ans)

Solution (Python):

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

money = 0

for word in s:
    money = max(money, s.count(word) - t.count(word))

print(money)

Solution (Python):
def resolve():
    table={}
    n=int(input())
    for i in range(n):
        tmp=input()
        if tmp in table.keys():
            table[tmp]+=1
        else:
            table[tmp]=1
    m=int(input())
    for i in range(m):
        tmp=input()
        if tmp in table.keys():
            table[tmp]-=1
        else:
            table[tmp]=-1
    ans=max(table.values())
    if ans<0:
        print(0)
    else:
        print(ans)
resolve()

Solution (Python):
N = int(input())
s= []
for i in range(N):
  s.append(input())

M = int(input())
t = []
for i in range(M):
  t.append(input())

import collections
c_s = collections.Counter(s)
c_t = collections.Counter(t)

ans = 0
for k,v in c_s.items():
  ans = max((c_s[k]-c_t[k]),ans)

print(ans)

Solution (Python):
N = int(input())
S = dict()
word = []
ans = 0
for i in range(N):
    s = input()
    if s not in word:
        word.append(s)
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

M = int(input())
T = dict()
for i in range(M):
    t = input()
    if t not in word:
        word.append(t)
    if t in T:
        T[t] += 1
    else:
        T[t] = 1

for w in word:
    if w in S and w in T:
        money = S[w] - T[w]
    elif w in S:
        money = S[w]
    else:
        money = -1 * T[w]
    if money > ans:
        ans = money
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
M = int(input())
T = Counter([input() for _ in range(M)])
ans = 0
for key in S.keys():
    ans = max(S.get(key) - T.get(key, 0), ans)
print(ans)

Solution (Python):
n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]
ans = 0
for s in s_list:
    score = s_list.count(s) - t_list.count(s)
    if ans < score:
        ans = score
print(ans)

Solution (Python):
n = int(input())
dict = {}
for _ in range(n):
    s = input()
    if s not in dict:
        dict[s] = 0
    dict[s] += 1

m = int(input())
for _ in range(m):
    t = input()
    if t not in dict:
        dict[t] = 0
    dict[t] -= 1
print(max(dict.values()) if max(dict.values()) > 0 else 0)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l = list(set(s))
print(max(0,max(s.count(l[i])-t.count(l[i]) for i in range(len(l)))))

Solution (Python):
N = int(input())
S = dict()
for _ in range(N):
    s = input()
    if s not in S:
        S[s] = 1
    else:
        S[s] += 1
M = int(input())
T = dict()
for _ in range(M):
    t = input()
    if t not in T:
        T[t] = 1
    else:
        T[t] += 1

ans = 0
for k, v in S.items():
    res = v
    if k in T:
        res -= T[k]
    ans = max(ans, res)

print(ans)

Solution (Python):
n = int(input())


a = list()
d = {}
for i in range(n):
    val = input()
    d[val] = d.get(val, 0)+1
k = int(input())
b = list()
for i in range(k):
    val = input()
    d[val] = d.get(val, 0)-1

val_sorted = sorted(d.items(), key=lambda x: x[1], reverse=True)
for i in val_sorted:
    if int(i[1]) < 0:
        print(0)
        break
    print(i[1])
    break

Solution (Python):
def l(): return [input() for _ in range(int(input()))]
p, m = l(), l()
c = 0
for s in set(p):
    c = max(p.count(s) - m.count(s), c)
print(c)

Solution (Python):
from collections import defaultdict
counter = defaultdict(int)
for _ in range(int(input())):
    counter[input()] += 1
for _ in range(int(input())):
    counter[input()] -= 1
print(max(0, max(counter.values())))

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    s.append(input())

m=int(input())
t=[]
for i in range(m):
    t.append(input())

w=list(set(s))
a=[0]
for i in range(len(w)):
    a.append(s.count(w[i])-t.count(w[i]))

print(max(a))

Solution (Python):
def L(P,K,x):
  for i in range(K):
    t = input()
    try:
      P[t]+=1*x
    except:
      P[t]=1*x
  return P

P = {"":0}

N = int(input())
P = L(P,N,1)
M = int(input())
P = L(P,M,-1)
print(max(P.values()))

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n = int(input())
s = [ input() for _ in range(n) ]
m = int(input())
t = [ input() for _ in range(m) ]

sc = Counter(s)
sck = list(sc.keys())
scv = list(sc.values())

tc = Counter(t)
tck = list(tc.keys())
tcv = list(tc.values())


ans = 0
for i in range(len(sc)):
    w = sck[i]
    p = scv[i]
    
    p2 = tc[w]
    
    M = p - p2
    ans = max(ans,M)
print(ans)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
sc = []
for i in range(n):
    sc.append(input())
ob = set(sc)
m = ii()
disc = []
for i in range(m):
    disc.append(input())

score = 0
for i in ob:
    score = max(score,sc.count(i)-disc.count(i))
print(score)

Solution (Python):
N = int(input())
s = list([str(input()) for _ in range(N)])
M = int(input())
t = list([str(input()) for _ in range(M)])
l = list(set(s) | set(t))

s_count, t_count = [0]*len(l), [0]*len(l)
for i in range(N):
    s_count[l.index(s[i])] += 1
for i in range(M):
    t_count[l.index(t[i])] += 1

ans_l = [0]
for i in range(len(l)):
    ans_l.append(s_count[i] - t_count[i])

print(max(ans_l))

Solution (Python):
import sys

def resolve():
    N = int(input())
    words = {"___": 0}
    for i in range(N):
        s = input()
        if s not in words:
            words[s] = 1
        else:
            words[s] += 1
    M = int(input())
    for i in range(M):
        t = input()
        if t not in words:
            words[t] = -1
        else:
            words[t] += -1
    print(max(words.values()))
    

if '__main__' == __name__:
    resolve()

Solution (Python):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    B = [iss() for _ in range(N)]
    M = ii()
    R = [iss() for _ in range(M)]
    ret = 0
    for b in B:
        ret = max(ret, B.count(b) - R.count(b))

    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
s = []
for _ in range(N):
    s.append(input())
M = int(input())
t = []
for _ in range(M):
    t.append(input())

say = set(s)



M = 0
for saying in say:
    M = max(M, s.count(saying) - t.count(saying))
print(M)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
for word in set(s):
    cnt = s.count(word) - t.count(word)
    ans = max(ans, cnt)
print(ans)

Solution (Python):
n = int(input())
S = [input() for _ in range(n)]
m = int(input())
T = [input() for _ in range(m)]
ans = 0
for s in S:
  ans = max(ans, S.count(s) - T.count(s))
print(ans)

Solution (Python):
n = int(input())
blue = [input() for i in range(n)]
m = int(input())
red = [input() for i in range(m)]
a = set(blue)
ans = []
for i in a:
  b = 0
  for j in range(n):
    if blue[j] == i:
      b += 1
  for j in range(m):
    if red[j] == i:
      b -= 1
  ans.append(b)
print(max(0, max(ans)))

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

ans = 0

for i in range(N):
    tmp = s.count(s[i]) - t.count(s[i])
    ans = max(ans,tmp)
    
print(ans)

Solution (Python):
N = int(input())
ls1 = []
ls2 = []
ls3 = []
ans = []
for i in range(N):
    s = input()
    ls1.append(s)
    ls3.append(s)
M = int(input())
for j in range(M):
    t = input()
    ls2.append(t)
    ls3.append(t)
k = set(ls3)
p = list(k)
for i in range(len(p)):
    ans.append(ls1.count(p[i])-ls2.count(p[i]))
print(max(0,max(ans)))

Solution (Python):
n = int(input())
s = [ input() for _ in range(n) ]
m = int(input())
t = [ input() for _ in range(m) ]
print( max( 0, max([ s.count(i)-t.count(i) for i in set(s) ]) ) )

Solution (Python):
import sys
sys.setrecursionlimit(300000)
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

N = I()
S = [input() for _ in range(N)]
M = I()
T = [input() for _ in range(M)]

d = defaultdict(int)
for s in S:
    d[s] += 1
for t in T:
    d[t] = max(0, d[t] - 1)

print(max(d.values()))

Solution (Python):
n=int(input())
word={}
for i in range(n):
    new=input()
    if new in word:
        word[new]+=1
    else:
        word[new]=1
m=int(input())
for i in range(m):
    new=input()
    if new in word:
        word[new]-=1
    else:
        word[new]=-1
        
print(max(0,max(word.values())))

Solution (Python):
n = int(input())
red =[]
for i in range(n):
  l = str(input())
  red.append(l)

m = int(input())
blue =[]
for i in range(m):
  l = str(input())
  blue.append(l)
  
import collections

cr = collections.Counter(red)
crs = list(cr.most_common())
cb = collections.Counter(blue)
cbs = list(cb.most_common())

result =[]

for i in range(len(cbs)):
  for j in range(len(crs)):
    if cbs[i][0]==crs[j][0]:
      result.append(crs[j][1]-cbs[i][1])
    else:
      flag = False
      count = 0
      for k in range(len(cbs)):
        if cbs[k].count(crs[j][0]) == 0:
          count+=1
      if count == len(cbs):
        result.append(crs[j][1])
        flag = False
        count = 0

if max(result)>0:
  print(max(result))
else:
  print(0)

Solution (Python):
n=int(input())
syugo=set()
S,T=[],[]
ans=0
for i in range(n):
    s=input()
    S.append(s)
    syugo.add(s)
m=int(input())
for i in range(m):
    t=input()
    T.append(t)
    syugo.add(t)
syugo=list(syugo) 
syugo.append("0")
for i in range(len(syugo)):
    sin=S.count(syugo[i])
    tin=T.count(syugo[i])
    if ans<sin-tin:
        ans=sin-tin
print(ans)

Solution (Python):
a=int(input())
b=[input() for i in range(a)]
c=int(input())
d=[input() for i in range(c)]
 
yen=0
for i in set(b):
    num=b.count(i)
    num2=d.count(i)
    yen=max(yen,num-num2)
print(yen)

Solution (Python):

import math



import collections
n = int(input())


s = []
for i in range(n):
    s.append(input())
m = int(input())
t = []
for j in range(m):
    t.append(input())

s2 = collections.Counter(s)
t2 = collections.Counter(t)
point = 0
ans  = 0


for i in s2.keys():
    for j in t2.keys():
        if i==j:
            point = s2.get(i)-t2.get(j)
            
            break
        else:
            point = s2.get(i)
    
    if ans < point:
        ans = point

print(ans)

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
st=s+t
u=set(s+t)
ans=0
for i in u:
  count=0
  for j in range(n+m):
    if i==st[j]:
      count+=1 if j<=n-1 else (-1)
  ans=max(ans,count)
print(ans)

Solution (Python):
N = int(input())
N_lis = []
for n in range(N):
  N_lis.append(input())
  
M = int(input())
M_lis = []
for m in range(M):
  M_lis.append(input())
  
ans = 0
for n in N_lis:
  x = N_lis.count(n) - M_lis.count(n)
  if x > ans:
    ans = x
print(ans)

Solution (Python):
import collections

n = int(input())
tmp = []
for _ in range(n):
    tmp.append(str(input()))
p = collections.Counter(tmp)
m = int(input())
for _ in range(m):
    p[str(input())]-=1

print(max(0, p.most_common()[0][1]))

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]  
M = int(input())
t = [input() for _ in range(M)]
ans = 0

for w in s:
  diff = s.count(w) - t.count(w)
  if diff > ans:
    ans = diff

print(ans)

Solution (Python):
n=int(input())
s=[""]*n
for i in range(n):
  s[i]=input()
m=int(input())  
t=[""]*m
for j in range(m):
  t[j]=input()
C=[0]
 
for i in range(n):
  p=s[i]
  c=s.count(str(s[i]))-t.count(str(s[i]))
  C.append(c)
  
print(max(C))

Solution (Python):
ans = -101

N = int(input())
N_list = []
for _ in range(N):
    N_list.append(input())

M = int(input())
M_list = []
for _ in range(M):
    M_list.append(input())

MN_list = N_list[:]
MN_list.extend(M_list)
MN_list = set(MN_list)

for word in MN_list:
    word_point = 0
    for item in N_list:
        if word == item:
            word_point += 1
    for item in M_list:
        if word == item:
            word_point -= 1
    ans = max(ans, word_point)

if ans < 0:
    print(0)
else:
    print(ans)

Solution (Python):
n = int(input())
list_S = [input() for _ in range(n)]
m = int(input())
list_T = [input() for _ in range(m)]
ans = 0
set_S = list(set(list_S))
for c in set_S:
    if list_S.count(c)-list_T.count(c)>0:
       ans =  max(ans, list_S.count(c)-list_T.count(c))

print(ans)

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

ss = collections.Counter(s)
tt = collections.Counter(t)
ans = 0
for i in ss:
    sub = ss[i]
    if i in tt:
        sub -= tt[i]
    ans = max(ans, sub)
    
print(ans)

Solution (Python):
from collections import defaultdict

cnt = defaultdict(int)

for m in range(2):
    n = int(input())
    for i in range(n):
        s = input()
        if m == 0:
            cnt[s] += 1
        else:
            cnt[s] -= 1

print(max(max(cnt.values()), 0))

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
s_count = 0
t_count = 0

for i in set(s):
    s_count = 0
    t_count = 0
    for j in s:
        if j == i:
            s_count += 1
    for k in t:
        if k == i:
            t_count +=1
    
    ans = max(ans, s_count - t_count)
print(ans)

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
A = [0]
for j in s:
  A.append(s.count(j) - t.count(j))
print(max(A))

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
u=set(s)
ans=0
for i in u:
    cnt=s.count(i)-t.count(i)
    ans=max(ans,cnt)
print(ans)

Solution (Python):
a = int(input())
al = []
for i in range(a):
  al.append(input())
b = int(input())
bl = []
for i in range(b):
  bl.append(input())
aa = list(set(al))
c =[]
for i in range(len(aa)):
  c.append(al.count(aa[i])-bl.count(aa[i]))
print(max(max(c),0))

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n = int(input())
  s = [input() for _ in range(n)]
  m = int(input())
  t = [input() for _ in range(m)]
  
  Nya = list(set(s))
  
  Ma = 0
  for i in range(len(Nya)):
    Fi = s.count(Nya[i])
    Se = t.count(Nya[i])
    Ma = max(Ma,Fi-Se)
  print(Ma)
    
    
    
if __name__ == '__main__':
  main()

Solution (Python):
n = int(input())
slis = []
for i in range(n):
    slis.append(input())
m = int(input())
tlis = []
for i in range(m):
    tlis.append(input())
x = 0
for i in set(slis):
    ok = slis.count(i)
    ng = tlis.count(i)
    x = max(x, ok-ng)
print(x)

Solution (Python):
n = int(input())
blue = []
for i in range(n):
  blue.append(input())
  
m = int(input())
red = []
for i in range(m):
  red.append(input())
  
s = set(blue)

maxnum = 0
for item in s:
  cnt = blue.count(item) - red.count(item)
  if cnt > maxnum:
    maxnum = cnt

print(maxnum)

Solution (Python):
import copy
import collections

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

l = copy.copy(s)
for i in range(n):
  if l[i] in t:
    s.remove(l[i])
    t.remove(l[i])

if not s:
  print(0)
else:
  num = collections.Counter(s)
  print(max(num.values()))

Solution (Python):
from  collections import  Counter
list1 = []
list2 = []

n1 = int(input())
for i in range(n1):
  list1.append(input())
n2= int(input())
for i in range(n2):
  list2.append(input())

set_list1 = set(list1)
Counter_list1  = Counter(list1)
set_list2 = set(list2)
Counter_list2 = Counter(list2)

ans = 0
for i in set_list1:
  dummy = Counter_list1[i] - Counter_list2[i]
  ans = max(ans,dummy)
print(ans)

Solution (Python):
N=int(input())
m = {}
for i in range(N):
  s = input()
  if s in m:
    m[s] += 1
  else:
    m[s] = 1
M=int(input())
for i in range(M):
  t = input()
  if t in m:
    m[t] -= 1
  else:
    m[t] = -1
ans = 0
for k,v in m.items():
  ans = max( ans, v )
print(ans)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
ans = 0
for s in S:
    ans = max(ans, S.count(s) - T.count(s))
print(ans)

Solution (Python):
from collections import Counter
n=int(input())
s = [input() for _ in range(n)]
m=int(input())
t = [input() for _ in range(m)]

def list_difference(s,t):
    l = s.copy()
    for value in t:
        if value in l:
            l.remove(value)
    return l
l=list_difference(s,t)
l1=Counter(l)
if len(l)>0:print(l1.most_common()[0][1])
else:print(0)

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())

for i in range(m):
    t = input()
    if t in s:
        s.remove(t)

c = collections.Counter(s)
c = list(c.most_common())
if c:
    print(c[0][1])
else:
    print(0)

Solution (Python):
N = int(input())
D = {}
for _ in range(N):
    s = input()
    if s not in D: D[s]=0
    D[s] += 1

M = int(input())
for _ in range(M):
    t = input()
    if t not in D: D[t]=0
    D[t] -= 1

print(max(0, max(D.values())))

Solution (Python):
import collections
n = int(input())
arr = []
for i in range(n):
  arr.append(input())
m = int(input())
for i in range(m):
  s = input()
  if s in arr:
    arr.remove(s)
if len(arr) == 0:
  print(0)
else:
  arr = collections.Counter(arr)
  print(arr.most_common()[0][1])

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
s2=dict()
t2=dict()
for i in range(n):
    if s[i] in s2:
        s2[s[i]]+=1
    else:
        s2[s[i]]=1
        t2[s[i]]=0
for i in range(m):
    if t[i] in t2:
        t2[t[i]]+=1
    else:
        t2[t[i]]=1
ans=0
for i in s2:
    ans=max(s2[i]-t2[i],ans)
print(ans)

Solution (Python):

def main():
    n, nn, nnn = map(int, input().split(' '))
    print('Yes' if n + nn >= nnn else 'No')


def main_b():
    t = int(input())
    ad = [input() for i in range(t)]
    t = int(input())
    mo = [input() for i in range(t)]

    from collections import Counter
    ad = dict(Counter(ad))
    mo = dict(Counter(mo))
    ans = 0
    for a in ad:
        tmp = ad.get(a, 0) - mo.get(a, 0)
        if ans < tmp:
            ans = tmp
    print(ans)
if __name__ == '__main__':
    main_b()

Solution (Python):

def main():
    n, nn, nnn = map(int, input().split(' '))
    print('Yes' if n + nn >= nnn else 'No')


def main_b():
    ad = {}
    mo = {}
    t = int(input())
    for i in range(t):
        c = input()
        ad.setdefault(c, 0)
        ad[c] += 1
    t = int(input())
    for i in range(t):
        c = input()
        mo.setdefault(c, 0)
        mo[c] += 1
    ans = 0
    for a in ad:
        tmp = ad.get(a, 0) - mo.get(a, 0)
        if ans < tmp:
            ans = tmp
    print(ans)
if __name__ == '__main__':
    main_b()

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
s.sort()
ans = 0
w = s[0]
c = 0
for i in s:
    if i == w:
        c += 1
    else:
        for j in t:
            if j == w:
                c -= 1
        if ans < c:
            ans = c
        c = 1
        w = i
for i in t:
    if i == w:
        c -= 1
if ans < c:
    ans = c
print(ans)

Solution (Python):
n=int(input())
s=[input() for x in range(n)]
m=int(input())
t=[input() for x in range(m)]

from collections import Counter
sd=dict(Counter(s))
td=dict(Counter(t))
ans=0
for x in sd:
    y=sd.get(x,0)-td.get(x,0)
    ans=max(y,ans)
print(ans)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

ls = []
ls.extend(s)
ls.extend(t)

ls = set(ls)
d = {l:0 for l in ls}

for sn in s:
    d[sn] += 1
for tn in t:
    d[tn] -= 1

d = sorted(d.items(),key = lambda x:x[1],reverse = True)
if d[0][1] > 0:
    print(d[0][1])
else:
    print(0)

Solution (Python):
from collections import defaultdict


def main():

    N = int(input())
    words = defaultdict(int)
    for _ in range(N):
        words[input()] += 1

    M = int(input())
    for _ in range(M):
        words[input()] -= 1

    words['len(word)>10'] = 0
    print(max(words.values()))


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter 
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

cs = Counter(s)
ct = Counter(t)
ans = 0
for k, v in cs.items():
    if k in ct.keys():
        ans = max(ans, v-ct[k])
    else:
        ans = max(ans, v)

print(ans)

Solution (Python):
n = int(input())
A = [input() for i in range(n)]
m = int(input())
B = [input() for i in range(m)]
T = [""] * n
ans = 0

for i in range(n):
    if A[i] not in T:
        T[i] = A[i]
        ans = max(ans, A.count(A[i]) - B.count(A[i]), 0)

print(ans)

Solution (Python):
n = int(input())
dict_s = {}
for i in range(n):
    s = input()
    dict_s[s] = dict_s.get(s, 0) + 1

m = int(input())
dict_t = {}
for i in range(m):
    t = input()
    dict_t[t] = dict_t.get(t, 0) + 1

ans = 0
for k, v in dict_s.items():
    add = v
    add -= dict_t.get(k, 0)
    ans = max(ans, add)

print(ans)

Solution (Python):


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate
    
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    

    
    

    N = int(input())
    a = []
    for _ in range(N):
        a.append(input().rstrip())
    M = int(input())
    b = []
    for _ in range(M):
        b.append(input().rstrip())
    s = set(a)
    res = 0
    for i in s:
        res = max(res, a.count(i)-b.count(i))
    print(res)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

cnt = 0
for x in s:
    cnt = max(s.count(x) - t.count(x), cnt)
print(cnt)

Solution (Python):
import collections
s = []
t = []
ans = 0

n = int(input())
for _ in range(n):
    s.append(input())
m = int(input())
for _ in range(m):
    t.append(input())

x = collections.Counter(s)
y = collections.Counter(t)

for i in x:
    t = x[i] - y[i]
    ans = max(t, ans)

print(ans)

Solution (Python):
N = int(input())
si = [input() for _ in range(N)]
M = int(input())
ti = [input() for _ in range(M)]

cnt = 0
for s in si:
  cnt = max(si.count(s)-ti.count(s), cnt)
print(cnt)

Solution (Python):

import collections
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
S_c = collections.Counter(S)
T_c = collections.Counter(T)
ans = 0

for s_word,s_count in S_c.items():
    if ans < s_count-T_c[s_word]:
        ans = s_count-T_c[s_word]

print(max(ans,0))

Solution (Python):
from collections import defaultdict
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
d = defaultdict(int)
for i in range(N):
    d[s[i]] += 1
for i in range(M):
    d[t[i]] -= 1
print(max(0,max(d.values())))

Solution (Python):
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))
m = int(input())
t = []
for i in range(m):
    t.append(str(input()))
all_card = []
card_point = []
for i in range(n):
    if s[i] in all_card:
        card_point[all_card.index(s[i])] += 1
    else:
        all_card.append(s[i])
        card_point.append(1)

for i in range(m):
    if t[i] in all_card:
        card_point[all_card.index(t[i])] -= 1
    else:
        all_card.append(t[i])
        card_point.append(-1)

print(max(0,max(card_point)))

Solution (Python):
key = dict()

n = int(input())
for i in range(n):
  k = input()
  if k in key:
    key[k] += 1
  else:
    key[k] = 1

m = int(input())

for i in range(m):
  k = input()
  if k in key:
    key[k] -= 1
  else:
    key[k] = -1

sub = []
for i in key.values():
  sub.append(i)
print(max([max(sub), 0]))

Solution (Python):
s = []
t = []
N = int(input())
for _ in range(N):
  s.append(str(input()))
M = int(input())
for _ in range(M):
  t.append(str(input()))

from collections import Counter
sc = Counter(s)
tc = Counter(t)
s_keys, s_values = zip(*sc.most_common())
t_keys, t_values = zip(*tc.most_common())
ans = 0
for i in range(len(s_values)):
  for j in range(len(t_values)):
    minus = 0
    if s_keys[i] == t_keys[j]:
      minus = t_values[j]
      ans = max(ans, s_values[i] - minus)
    if s_keys[i] not in t_keys:
      ans = max(ans, s_values[i])
print(ans)

Solution (Python):
n=int(input())
s=[]
for i in range(n):
        s.append(input())
m=int(input())
t=[]
for i in range(m):
        t.append(input())

ans=0
for w in s:
    now=0
    for blue in s:
        if w==blue:
            now+=1

    for red in t:
        if w==red:
            now-=1
    ans=max(ans,now)
print(ans)

Solution (Python):
s = []
t = []
N = int(input())
for _ in range(N):
    s.append(input())
M = int(input())
for _ in range(M):
    t.append(input())
s_set = set(s)
s_list = list(s_set)
c = []
count = 0
for i in range(len(s_list)):
    for j in range(len(s)):
        if s_list[i] == s[j]:
            count += 1
    for k in range(len(t)):
        if s_list[i] == t[k]:
            count -= 1
    c.append(count)
    count = 0
ans = max(c)
if ans > 0:
    print(ans)
else:
    print(0)

Solution (Python):
N = int(input())
dic = {}
for i in range(N):
  s = input()
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1
  
M = int(input())
for i in range(M):
  t = input()
  if t not in dic:
    dic[t] = -1
  else:
    dic[t] -= 1

print(max(0,max(dic.values())))

Solution (Python):
n = int(input())
list_s = list(input() for i in range(n))
m = int(input())
list_t = list(input() for i in range(m))
count =0
set_s =list(set(list_s))
for i in set_s:
  count = max(count,list_s.count(i)-list_t.count(i))
print(count)

Solution (Python):
n=int(input())
from collections import Counter
cc=Counter()
for _ in range(n):
    cc[input()]+=1
m=int(input())
ans=0
for _ in range(m):
    x=input()
    if cc[x]==0:
        continue
    else:
        cc[x]-=1
for i in cc:
    ans=max(ans,cc[i])
print(ans)

Solution (Python):
from collections import Counter
N=int(input())
s=[0]*N

for i in range(N):
    s[i]=input()
M=int(input())
t=[0]*M
for j in range(M):
    t[j]=input()

c=dict(Counter(s))
d=dict(Counter(t))
maxi=0



for item in c:
    if item in d:
        tmp = c[item]-d[item]
    else:
        tmp = c[item]
    maxi=max(maxi, tmp)
   
print(maxi)