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())
l=[str(input()) for i in range(n)]
m=int(input())
r=[str(input()) for i in range(m)]
l.sort();r.sort()

ans=0
for i in range(n):
    a=l[i]
    b=l.count(l[i])-r.count(l[i])
    if ans<=b:
        ans=b
print(ans)

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

for i in set(s):
    Y = max(Y,s.count(i) - t.count(i))
print(Y)

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

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

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

c = [0]
for i in s:
  c.append(s.count(i) - t.count(i))
  
print(max(c))

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 set(S):
    p = S.count(s)
    m = T.count(s)
    if p > m:
        ans = max(ans, p-m)

print(ans)

Solution (Python):
def resolve():
    from collections import defaultdict
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[input()] += 1
    M = int(input())
    for _ in range(M):
        d[input()] -= 1
    res = 0
    for _,v in d.items():
        if v > res:
            res = v
    print(res)
resolve()

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

Words = list(set(B)) + list(set(R))

ans = 0
for w in Words:
	ans = max(ans, B.count(w) - R.count(w))

print(ans)

Solution (Python):
n = int(input())
sn = [input() for _ in range(n)]
m = int(input())
sm = [input() for _ in range(m)]

List = []
for i in range(len(list(set(sn)))):
    List.append(sn.count(list(set(sn))[i]) - sm.count(list(set(sn))[i]))
    
print(max(max(List), 0))

Solution (Python):
word=[]
max_score=0

n=int(input())
for i in range(n):
    s=input()
    word.append([s,1])
m=int(input())
for i in range(m):
    s=input()
    word.append([s,-1])
word2=sorted(word)

now=word2[0][0]
score=0
for i in range(n+m):
    if now==word2[i][0]:
        score+=word2[i][1]
    else:
        if score>max_score:
            max_score=score
        score=0
        score+=word2[i][1]
        now=word2[i][0]
print(max(score,max_score))

Solution (Python):
import collections

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

counter_s = collections.Counter(s)
ans = 0
for k, v in counter_s.items():
    ans = max(ans, v - t.count(k))
print(ans)

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

ans_list = []
for i in range(N):
    say_word = s[i]
    ans_list.append(s.count(say_word) - t.count(say_word))

print(max(max(ans_list),0))

Solution (Python):
from collections import Counter

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

s_count, t_count = Counter(s), Counter(t)

for i in s_count:
    tmp_s = s_count[i]
    tmp_t = 0
    if i in t_count:
        tmp_t = t_count[i]

    if output < tmp_s - tmp_t:
        output = tmp_s - tmp_t

print(output)

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

Solution (Python):
n=int(input())
s_list=[input() for i in range(n)]
m=int(input())
t_list=[input() for i in range(m)]
l_list=list(set(s_list))
a=max(0,max(s_list.count(l_list[i-1])-t_list.count(l_list[i-1]) for i in range(len(l_list))))
print(a)

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    r = collections.Counter([str(input().rstrip('\n')) for _ in range(n)])
    m = int(input().rstrip('\n'))
    b = collections.Counter([str(input().rstrip('\n')) for _ in range(m)])
    mt = 0
    for k, v in r.items():
        if k in b:
            if v > b[k]:
                mt = max(mt, v - b[k])
        else:
            mt = max(mt, v)
    print(mt)


if __name__ == '__main__':
    slove()

Solution (Python):
import collections
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
sc=collections.Counter(s)
tc=collections.Counter(t)
ans=sc-tc
print(max(ans[i] for i in ans) if len(ans)>0 else 0)

Solution (Python):
import collections
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
u=set(s)
ans=0
for i in u:
    p=s.count(i)-t.count(i)
    ans=max(ans,p)
print(ans)

Solution (Python):
import collections
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cs=collections.Counter(s)
ct=collections.Counter(t)
ans=0
for k,v in cs.items():
    mp=0
    if k in ct:
        mp=ct[k]
    ans=max(ans, v-mp)
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)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[x]-=1
table=table.values()
table=[x for x in table if x >= 0]
table.append(0)
print(max(table))

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

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

max_v = 0
for i in range(N):
    max_v = max(s.count(s[i]) - t.count(s[i]), max_v)

print(max_v)

Solution (Python):
N = int(input())
S = [input().strip() for _ in range(N)]
M = int(input())
T = [input().strip() for _ in range(M)]
cntmax = 0
for s in S:
    cnt = S.count(s)
    for t in T:
        if t==s:
            cnt -= 1
    cntmax = max(cntmax,cnt)
print(cntmax)

Solution (Python):
from collections import Counter
N=int(input())
S=[]
T=[]
for n in range(N):
    s=input()
    S.append(s)
M=int(input())
for m in range(M):
    t=input()
    T.append(t)
d_s=Counter(S)
d_t=Counter(T)
if len(d_s-d_t)==0:
    print(0)
else:
    u=sorted((d_s-d_t).items(), key=lambda x:x[1], reverse=True)
    
    print(u[0][1])

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

get_money = []

for word in n_list:
    plus = [i for i, j in enumerate(n_list) if j == word]
    plus = len(plus)
    minus = [i for i, j in enumerate(m_list) if j == word]
    minus = len(minus)
    price = 1*plus - 1*minus
    get_money.append(price)

ans = max(get_money)
if ans > 0:
    print(ans)
else:
    print(0)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ans = 0
count1 = 0
count2 = 0
for i in range(N):
  for j in range(N):
    if S[i] == S[j]:
      count1 += 1
  for k in range(M):
    if S[i] == T[k]:
      count2 += 1
  ans = max(ans,count1-count2)
  count1 = 0
  count2 = 0
print(ans)

Solution (Python):
from collections import defaultdict
N = int(input())
bd = defaultdict(lambda: 0)
for i in range(N):
  bd[input()] += 1
N = int(input())
for i in range(N):
  bd[input()] -= 1

print(max([max(bd.values()), 0]))

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

l = n.copy()
l.extend(m)
l = set(l)

prize = [n.count(cand_i) - m.count(cand_i) for cand_i in l]
print(max(0, max(prize)))

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

Solution (Python):
S = [input() for _ in range(int(input()))]
T = [input() for _ in range(int(input()))]
ans = 0
for s in set(S):
    score = S.count(s) - T.count(s)
    if score > ans:
        ans = score
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
r = [input() for _ in range(N)]
r1 = Counter(r)
M = int(input())
b = [input() for _ in range(M)]
b1= Counter(b)


ans = 0
for i in r1.keys():
  if i in b1:
    ans = max(ans,r1[i]-b1[i])
  else:
    ans = max(ans,r1[i])
print(ans)

Solution (Python):


input_line = open(0).readlines()
N = int(input_line[0])
s = [i.rstrip("\n") for i in input_line[1:1+N]]
M = int(input_line[1+N])
t = [i.rstrip("\n") for i in input_line[2+N:2+N+M]]

s_set = set(s)
cnt_list = []
for i in range(len(s_set)):
    ele_cnt = max(s.count(list(s_set)[i])-t.count(list(s_set)[i]), 0)
    cnt_list.append(ele_cnt)

print(max(cnt_list))

Solution (Python):
n = int(input())
s = []
for i in range(n):
    a = input()
    s.append(a)
m = int(input())
t = []
for i in range(m):
    a = input()
    t.append(a)
c = []
k = 0
for i in s:
    for j in s:
        if i == j:
            k += 1
    for j in t:
        if i == j:
            k -= 1
    c.append(k)
    k = 0
if max(c) < 0:
    print(0)
else:
    print(max(c))

Solution (Python):
w_map = {}

for i in range(0, int(input())):
    s = input()
    if s in w_map:
        w_map[s] += 1
    else:
        w_map[s] = 1

for i in range(0, int(input())):
    t = input()
    if t in w_map:
        w_map[t] -= 1
    else:
        w_map[t] = -1

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

Solution (Python):
s_list = []
t_list = []

for i in range(0, int(input())):
    s_list.append(input())

for i in range(0, int(input())):
    t_list.append(input())

w_map = {}
for s in s_list:
    if s in w_map:
        w_map[s] += 1
    else:
        w_map[s] = 1

for t in t_list:
    if t in w_map:
        w_map[t] -= 1
    else:
        w_map[t] = -1

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

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ss = set(s)
b = 0
for i in ss:
    a = 0
    for l in s:
        if l == i:
            a += 1
    for l in t:
        if l == i:
            a -= 1
    if a > b:
        b = a
print(b)

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

Solution (Python):
from collections import Counter

def bb091():
    n = int(input())
    sn = Counter()
    sn['0'] = 0
    for i in range(0,n):
        sn[input()] += 1

    m = int(input())
    tm = Counter()
    for i in range(0,m):
        tm[input()] += 1

    for k,v in tm.items():
        sn[k] -= v

    ma = 0
    for k,v in sn.items():
        if v > ma:
            ma = v

    print(ma)

bb091()

Solution (Python):
N = int(input())
red = dict()
blue = dict()

for n in range(N):
  r = input()
  if r in red:
    red[r] += 1
  else:
    red[r] = 1

M = int(input())

for m in range(M):
  b = input()
  if b in blue:
    blue[b] += 1
  else:
    blue[b] = 1

ret = [0]
for k in red.keys():
  cnt = red[k] - (blue[k] if k in blue else 0)
  ret.append(cnt)

print(max(ret))

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 set(s):
    ans = max(ans, s.count(i) - t.count(i))
print(ans)

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

M = int(input())
for _ in range(M):
    t = input()
    if t in dic: 
        dic[t] -= 1
ans = max(dic.values())
if ans<0:
    print(0)
else:
    print(ans)

Solution (Python):
from collections import defaultdict
dic=defaultdict(int)
n=int(input())
for i in range(n):
    s=input()
    dic[s]+=1
m=int(input())
for i in range(m):
    s=input()
    dic[s]-=1

ans=float('-inf')
for i in dic.values():
    ans=max(ans,i)
print(max(ans,0))

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

Solution (Python):
from collections import defaultdict
N = int(input())
S = defaultdict(int)
S_item = []
for _ in range(N):
    s = input()
    S[s] += 1
    S_item += [s]
M = int(input())
T = defaultdict(int)
T_item = []
for _ in range(M):
    t = input()
    T[t] += 1
    T_item += [t]
ans = 0
for item in S_item:
    if item not in T_item:
        ans = max(ans, S[item])
    else:
        ans = max(ans, S[item]-T[item])
print(ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
res = 0
for s in set(S):
    score = S.count(s) - T.count(s)
    if score > res:
        res = score
print(res)

Solution (Python):
s = [input() for i in range(int(input()))]
t = [input() for i in range(int(input()))]
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 = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
point = 0
s.sort() 
t.sort() 
l = list(set(s))
for i in l:
    tmp = s.count(i) - t.count(i) 
    point = max(point,tmp)

print(point)

Solution (Python):
import collections

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

s = collections.Counter(s)
t = collections.Counter(t)
ans = 0
for k in s:
    ans = max(ans, s[k] - t[k])
print(ans)

Solution (Python):
blue_num = int(input())
blue_list = []
[blue_list.append(input()) for i in range(blue_num)]
red_num = int(input())
red_list = []
[red_list.append(input()) for n in range(red_num)]

count_list = []
for i in blue_list:
    count = 0
    count += blue_list.count(i)
    for j in red_list:
        if i == j:
            count -= 1
        else:
            pass
    count_list.append(count)


if max(count_list) <= 0:
    print(0)
else:
    print(max(count_list))

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

sarr = []

for i in range(n):
    sarr.append(input())

m = int(input())

tarr = []

for i in range(m):
    tarr.append(input())

dic = {}

sset = list(set(sarr))
tset = list(set(tarr))

for i in range(len(sset)):
    dic[sset[i]] = sarr.count(sset[i]) - tarr.count((sset[i]))

ans = max(dic.values())

if ans < 0:
    ans = 0

print(ans)

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

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())
    
dic = {}
for i in range(N):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
for i in range(M):
    if T[i] in dic:
        dic[T[i]] -= 1
    
ans = 0
for key in dic:
    if ans < dic[key]:
        ans = dic[key]
        
print(ans)

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

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
check={}
for c in s:
    if c not in check:
        check[c]=1
    else:
        check[c]+=1
for c in t:
    if c in check:
        check[c]-=1
M=0
for c in check:
    M=max(M,check[c])
print(M)

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

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

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

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

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

ans = []

cs = Counter(s)
ct = Counter(t)

for i in range(len(cs)):
        ans.append(cs.most_common()[i][1] - t.count(cs.most_common()[i][0]))
print(max(max(ans), 0))

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())
  
out = 0

s_uniq = set(s)
for i in s_uniq:
  c = len([x for x in s if x == i]) - len([x for x in t if x == i])
  if out < c:
    out = c

print(out)

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

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 s:
  ans=max(ans, s.count(i)- t.count(i))
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())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
Y = 0

for i in set(s):
    Y = max(Y,s.count(i) - t.count(i))
print(Y)

Solution (Python):

import collections


def main():


    N = int(input())
    sList = [input() for _ in range(N)]
    M = int(input())
    tLIst = [ input() for _ in range(M)]
    sDict = collections.Counter(sList)
    tDict = collections.Counter(tLIst)
    sDict.subtract(tDict)
    ansList = []
    for i in sDict:
        ansList.append(sDict[i])
    print(max(ansList)if max(ansList) > 0 else 0)






if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
sn = list(input() for i in range(n))
m = int(input())
mn = list(input() for i in range(m))
ss = []
for i in range(len(sn)):
  ss.append(sn.count(sn[i])-mn.count(sn[i]))
print (max(max(ss),0))

Solution (Python):
import collections

n = int(input())

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

m = int(input())

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

s_num = collections.Counter(s)
t_num = collections.Counter(t)

ans = 0
for key in s_num:
    if key in t_num:
        ans = max(ans, s_num[key] - t_num[key])
    else:
        ans = max(ans, s_num[key])

print(ans)

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
l =[0]*n
for j in range(n):
  a = s.count(s[j])
  b = t.count(s[j])
  l[j] = a-b
print(max(max(l),0))

Solution (Python):
from collections import Counter
n = int(input())
s = list(input() for hoge in range(n))
m = int(input())
t  = list(input() for hoge in range(m))
scount = Counter(s)
tcount = Counter(t)
maxyen = 0
for i in range(n):
         if (scount[s[i]] - tcount[s[i]]) > maxyen:
                  maxyen = (scount[s[i]] - tcount[s[i]])
print(maxyen)

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

ans_dic = sorted(dic.items(),key=lambda x:x[1],reverse = True)
print( max(ans_dic[0][1], 0))

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)
d2 = defaultdict(int)
for k in S:
    d[k] += 1
    d2[k] = 0

for k in d2:
    d2[k] = S.count(k) - T.count(k)

d2 = sorted(d2.items(), key=lambda x: x[1], reverse=True)

print(d2[0][1] if d2[0][1] >= 0 else 0)

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

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

for i in s:
    cnt = s.count(i) - t.count(i)
    if yMax < cnt:
        yMax = cnt
print(yMax)

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

for i in s:
    cnt = s.count(i) - t.count(i)
    if yenMax < cnt:
        yenMax = cnt
print(yenMax)

Solution (Python):
N = int(input().strip())
S = [input().strip() for _ in range(N)]
M = int(input().strip())
T = [input().strip() for _ in range(M)]

ans = 0
for w in set(S):
  ans = max(ans, S.count(w)-T.count(w))
print(max(0,ans))

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

Solution (Python):
s = [input() for n in range(int(input()))]
t = [input() for m in range(int(input()))]
l=list(set(s))
ans = max( s.count(l[i]) - t.count(l[i]) for i in range(len(l)) )
print(max(0, 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)]

print(max([0] + [v - t.count(k) for k, v in Counter(s).items()]))

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)])

s.subtract(t)

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

Solution (Python):
import collections

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

counter1 = collections.Counter(s)
counter2 = collections.Counter(t)
ans = max(counter1[k] - counter2[k] for k in counter1)
print(max(ans, 0))

Solution (Python):
import collections

n = int(input())
ss = collections.Counter([input().strip() for _ in range(n)])
m = int(input())
ts = collections.Counter([input().strip() for _ in range(m)])

res = 0
for key, val in ss.items():
    res = max(res, val - ts[key])
print(res)

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

from collections import Counter

blue = Counter(S)
red = Counter(T)

pnt = []

for b in blue:
    if b in red:
        pnt.append(blue[b] - red[b])
    else:
        pnt.append(blue[b])
        
print(max(pnt) if max(pnt) > 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)]
ans = 0
for i in range(N):
    ans = max(ans, s.count(s[i])-t.count(s[i]))
print(ans)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
from collections import defaultdict
a = defaultdict(int)

for i in S:
    a[i] += 1
for i in T:
    a[i] -= 1
    
ans = 0
for i in a:
    if a[i] > ans:
        ans = a[i]
        
print(ans)

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

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

for i in range(len(s)):
    cnt.append(s.count(s[i]) - t.count(s[i]))
print(max(max(cnt),0))

Solution (Python):
n = int(input())
s_list = [input() for _ in range(n)]
m = int(input())
t_list = [input() for _ in range(m)]

cand_str_set = set(s_list)

calced_list = [(s_list.count(str_i) - t_list.count(str_i)) for str_i in cand_str_set]
calced_list.append(0)

print(max(calced_list))

Solution (Python):
import numpy as np

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

s = np.array(s)
t = np.array(t)
s_uni = np.unique(s)

ans = 0
for i,ch_s in enumerate(s_uni):
  ans_tmp = (s==ch_s).sum()
  ans_tmp -= (t==ch_s).sum()
  if ans_tmp > ans:
    ans = ans_tmp
print(int(ans))

Solution (Python):
import collections
N = int(input())
s = [input() for i in range(N)]
s = collections.Counter(s)
s = list(s.items())
M = int(input())
t = [input() for i in range(M)]
ans = 0
for i in s:
  count = 0
  for j in t:
    if i[0] == j:
      count += 1
  if ans <= i[1] - count:
    ans = i[1] - count
print(ans)

Solution (Python):

import sys
from collections import deque, defaultdict
import copy
import bisect

import math
import heapq
from itertools import combinations, permutations

import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
ans = 0
mozi = defaultdict(int)
for i in range(N):
	s = input()
	mozi[s] += 1
M = int(input())
for i in range(M):
	t = input()
	mozi[t] -= 1

for i in mozi:
	ans = max(ans, mozi[i])
print(ans)

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

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

ans=0
for a in range(0,N):
  A=NList.count(NList[a])-MList.count(NList[a])
  if A >ans:
    ans = A
    
if ans >0:
  print(ans)
else:
  print(0)

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(w)-t.count(w) for w in set(s))))

Solution (Python):
from collections import Counter

N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
sl = Counter(s)
tl = Counter(t)
ans = [0]

for i in range(len(sl)):
    if list(sl)[i] in tl:
        ans.append(sl[list(sl)[i]] - tl[list(sl)[i]])
    else:
        ans.append(sl[list(sl)[i]])

print(max(ans))

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
s = dict()
for _ in range(n):
    i = input()[:-1]
    if (s.get(i) == None):
        s[i] = 1
    else:
        s[i] += 1
m = int(input())
for _ in range(m):
    i = input()[:-1]
    if (s.get(i) == None):
        s[i] = -1
    else:
        s[i] -= 1
print(max(max(s.values()), 0))

Solution (Python):
from collections import defaultdict

s = defaultdict(int)

N = int(input())
for _ in range(N):
	s[input()] += 1
M = int(input())
for _ in range(M):
	s[input()] -= 1

answer = max(s.values())
if answer < 0:
	answer = 0
print(answer)

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

Solution (Python):
s = [input() for i in range(int(input()))]
t = [input() for i in range(int(input()))]
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())
A, B = map(int,input().split())
lst = [list(map(int,input().split())) for i in range(M)]
A = list(map(int,input().split()))
"""

from collections import Counter

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

S_cnt = list(Counter(S).items())


lst = []
for i in range(len(S_cnt)):
  point = S_cnt[i][1]
  for j in range(len(T)):
    if T[j] == S_cnt[i][0]:
      point -= 1
  lst.append(point)
ans = max(0, max(lst))
print(ans)

Solution (Python):
n=int(input())
t = [input() for i in range(n)] 
m=int(input())
q= [input() for i in range(m)] 
z=set(t)
base=[0]
for i in z:
  base.append(t.count(i)-q.count(i))
print(max(base))

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

Solution (Python):
n = int(input())
s = [list(map(str,input().split())) for i in range(n)]
m = int(input())
t = [list(map(str,input().split())) for i in range(m)]


c=0
for i in range(n):
    c=max(c,s.count(s[i])-t.count(s[i]))

print(c)

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())
import collections
bc = collections.Counter(Blue)
rc = collections.Counter(Red)

BL = list(bc.keys())

m = 0

for bl in BL:
  m = max(bc.get(bl)-rc.get(bl,0),m)
  
print(m)

Solution (Python):
def main():
  n = int(input())
  plus = {}
  for i in range(n):
    p_key = input()
    if plus.get(p_key) is None:
      plus[p_key] = 1
    else:
      plus[p_key] += 1
  m = int(input())
  minus = {}
  for i in range(m):
    m_key = input()
    if plus.get(m_key) is None:
      plus[m_key] = -1
    else:
      plus[m_key] -= 1
  
  for k in plus.keys():
    if minus.get(k) is None:
      pass
    else:
      plus[k] += minus[k]
  
  res = 0
  for v in plus.values():
    res = max(res, v)    
  print(res)
  return 0

if __name__ == "__main__":
  main()

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

from collections import Counter

blue = Counter(S)
red = Counter(T)

point = []

for bkey in blue:
    if bkey in red:
        point.append(blue[bkey] - red[bkey])
    else:
        point.append(blue[bkey])
        
print(max(point) if max(point) > 0 else 0)

Solution (Python):
n = int(input())
blues = [input() for _ in range(n)]
m = int(input())
reds = [input() for _ in range(m)]
words = set(blues)
_max = 0
for w in words:
    score = 0
    score += blues.count(w)
    score -= reds.count(w)
    if _max < score:
        _max = score
print(_max)