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())
sn=[input() for _ in range(n)]
m=int(input())
sm=[input() for _ in range(m)]
l=list(set(sn))
print(max(0,max([sn.count(l[i])-sm.count(l[i]) for i in range(len(l))])))

Solution (Python):
from collections import defaultdict
dicS = defaultdict(lambda: 0)
dicT = defaultdict(lambda: 0)
N = int(input())
S=[input() for i in range(N)]
M = int(input())
T=[input() for i in range(M)]
for s in S:
    dicS[s]+=1
for t in T:
    dicT[t]+=1
ans=0
for word, cnt in dicS.items():
    ans = max(ans, cnt-dicT[word])
print(ans)

Solution (Python):
from collections import Counter
import random

N = int(input())
s = []
for n in range(N):
    s.append(input())

M = int(input())
T = []
for m in range(M):
    T.append(input())


count_s = Counter(s)

for t in range(len(T)):
    if T[t] in count_s:
        count_s[T[t]] -= 1
    else:
        count_s[T[t]] = -1

count_s[str(random.random())] = 0

print(max(count_s.values()))

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    g = {}
    for i in range(n):
        s = input()
        if s in g:
            g[s] += 1
        else:
            g[s] = 1
    
    m = f()[0]
    for i in range(m):
        s = input()
        if s in g:
            g[s] -= 1
        else:
            g[s] = -1

    mxv = 0
    for k,v in g.items():
        mxv = max(mxv, v)
    
    print(mxv)

solve()

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

set_s = set(s)
ans = 0

for i in set_s:
    ans = max(ans, s.count(i) - t.count(i))

print(ans)

Solution (Python):
blue_n = int(input())
blue_card = [input() for i in range(blue_n)]
red_n = int(input())
red_card = [input() for i in range(red_n)]

set_s = set(blue_card)
max_v = 0
for s in set_s:  
  num = blue_card.count(s) - red_card.count(s)
  max_v = max(max_v, num)
print(max(0, max_v))

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

result = 0

for i in set(blue):
    x = blue.count(i) - red.count(i)
    if x > 0 and x > result:
        result = x

print(result)

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=[]
for i in s:
    l+=[s.count(i)-t.count(i)]
print(max(max(l),0))

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

st_list=list(set(s_list)|set(t_list))
ans_list=[]
for k in range(len(st_list)):
    ans_list.append(s_list.count(st_list[k])-t_list.count(st_list[k]))

ans_list.sort()
if ans_list[-1]>=0:
    ans=ans_list[-1]
else:
    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 = list(set(S))
ans = 0
for i in range(len(l)):
    ans = max(S.count(l[i])-T.count(l[i]),ans)
print(ans)

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

s = [input() for _ in range(N)]
u = list(set(s))

M = int(input())
t = [input() for _ in range(M)]

v = []
for i in range(len(u)):
  v.append(s.count(u[i]) - t.count(u[i]))
  
print(max(v) if max(v) >= 0 else 0)

Solution (Python):
from collections import Counter
def main(s, t):
    s_c = sorted(Counter(s).items(), key=lambda x: -x[1])
    t_c = Counter(t)
    tmp = 0
    for k, v in s_c:
        minus = t_c[k] if k in t_c.keys() else 0
        tmp = max(tmp, v - minus)
    print(tmp)

if __name__ == '__main__':
    N = int(input().strip())
    s = [input().strip() for _ in range(N)]
    M = int(input().strip())
    t = [input().strip() for _ in range(M)]
    main(s, t)

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

M = int(input())
t = []
for j in range(M):
    t += [str(input())]


ans = 0
for k in s:
    ans = max(ans, s.count(k) - t.count(k))
print (ans)

Solution (Python):
s=[]
t=[]
check=[]
cnt=0
max=0
B=int(input())
s=[input() for i in range(B)]
R=int(input())
t=[input() for i in range(R)]
s.sort()
check=list(set(s))

for i in range(len(check)):
	for j in range(R):
		if check[i]==t[j]:
			cnt+=1
	if max<s.count(check[i])-cnt:
		max=s.count(check[i])-cnt
	cnt=0

print(max)

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

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



if __name__ == '__main__':
    main()

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=0
  for j in range(n):
    if s[i] == s[j]:
      tmp+=1
  for j in range(m):
    if s[i] == t[j]:
      tmp-=1
  ans=max(ans,tmp)
print(ans)

Solution (Python):

from collections import defaultdict

def read_input():
    n = int(input())
    blue_cards = []
    for i in range(n):
        blue_cards.append(input())

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

    return n, m, blue_cards, red_cards

def submit():
    n, m, blue_cards, red_cards = read_input()

    blue_file = defaultdict(int)
    for b in blue_cards:
        blue_file[b] += 1

    red_file = defaultdict(int)
    for r in red_cards:
        red_file[r] += 1

    all_words = set(list(blue_file.keys()) + list(red_file.keys()))

    x = 0
    for word in all_words:
        p = blue_file[word] - red_file[word]
        if p > x:
            x = p

    print(x)



if __name__ == '__main__':
    submit()

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

ma = 0
for s in S.keys():
    if s in T:
        ma = max(ma, S[s] - T[s])
    else:
        ma = max(ma, S[s])

print(ma)

Solution (Python):
from collections import Counter

st1 = Counter([input() for _ in range(int(input()))])
st2 = Counter([input() for _ in range(int(input()))])

print(max(0, max([st1[key] - st2[key] for key in st1.keys()])))

Solution (Python):
from collections import Counter

n = int(input())
st1 = [input() for _ in range(n)]
m = int(input())
st2 = [input() for _ in range(m)]

st1_cnt = Counter(st1)
st2_cnt = Counter(st2)

gain = []
for key in st1_cnt.keys():
    gain.append(st1_cnt[key] - st2_cnt[key])
gain.append(0)

print(max(gain))

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=0
	for j in range(n):
		if s[i]==s[j]:
			tmp+=1
	for j in range(m):
		if s[i]==t[j]:
			tmp-=1
	ans=max(ans,tmp)
print(ans)

Solution (Python):
N=int(input())
n=[]
S=set()
for i in range(N):
  A=input()
  n.append(A)
  S.add(A)
M=int(input())
m=[]
for i in range(M):
  A=input()
  m.append(A)
  S.add(A)
P=[0]
for i in S:
  P.append(n.count(i)-m.count(i))
print(max(P))

Solution (Python):

n = int(input())
lst_1 = [input().rstrip() for _ in range(n)]
set_1 = set(lst_1)
m = int(input())
lst_2 = [input().rstrip() for _ in range(m)]
count = 0

for i in set_1:
    count = max(count, lst_1.count(i) - lst_2.count(i))

print(count)

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

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

Ss = []
for i in range(N):
    Ss.append(input())

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

hs = {}

for s in Ss:
    if s in list(hs.keys()):
        hs[s] += 1
    else:
        hs[s] = 1

for t in Ts:
    if t in list(hs.keys()):
        hs[t] -= 1

print(max(max([i[1] for i in hs.items()]),0))

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

Solution (Python):
from collections import defaultdict
def main():
	N = int(input())
	S = [""]*N
	cards = defaultdict(int)
	for i in range(N):
		S[i] = input()
		cards[S[i]] += 1
	M = int(input())
	T = [""]*M
	for i in range(M):
		T[i] = input()
		cards[T[i]] -= 1

	ans = 0
	for v in cards.values():
		ans = max(ans, v)

	print(ans)


if __name__ == '__main__':
	main()

Solution (Python):
d = {}
n = int(input())
for _ in range(n):
    e = input()
    if e not in d:
        d[e] = 1
    else:
        d[e] += 1
m = int(input())
for _ in range(m):
    e = input()
    if e not in d:
        d[e] = -1
    else:
        d[e] -= 1

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

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

d = dict((s - t).most_common(1))
print(list(d.values())[0] if d else 0)

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

Solution (Python):
def make_dict(S):
  dic = dict()
  for s in S:
    if s in dic:
      dic[s] += 1
    else:
      dic[s] = 1
  return dic

N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
blue = make_dict(S)
red = make_dict(T)
ans = 0
for s in blue.keys():
  tmp = blue[s]
  if s in red:
    tmp -= red[s]
  ans = max(ans,tmp)
print(ans)

Solution (Python):
def make_dict(S):
  dic = dict()
  for s in S:
    if s in dic.keys():
      dic[s] += 1
    else:
      dic[s] = 1
  return dic

N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]
blue = make_dict(S)
red = make_dict(T)
ans = 0
for s in blue.keys():
  tmp = blue[s]
  if s in red.keys():
    tmp -= red[s]
  ans = max(ans,tmp)
print(ans)

Solution (Python):
n=int(input())
b=[input()for _ in range(n)]
d={l:b.count(l)for l in set(b)}
m=int(input())
for _ in range(m):
  s=input()
  if s in d.keys():
    d[s]-=1
print(max(list(d.values())+[0]))

Solution (Python):

import sys
from collections import Counter
INF = float("inf")


def solve(N: int, s: "List[str]", M: int, t: "List[str]"):
    m = 0
    rec = ""
    sc = Counter(s)
    st = Counter(t)
    for c, v in sc.items():
        if m < v - st[c]:
            rec = c
            m = v - st[c]
    print(m)

    return


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):
n = int(input())
ss = {}
for i in range(n):
    s = input().strip()
    if s in ss:
        ss[s] += 1
    else:
        ss[s] = 1

m = int(input())
ts = {}
for i in range(m):
    s = input().strip()
    if s in ts:
        ts[s] += 1
    else:
        ts[s] = 1

max_score = 0
for s, sc in ss.items():
    tc = ts[s] if s in ts else 0
    max_score = max(max_score, sc - tc)

print(max_score)

Solution (Python):
N = int(input())
s = [str(input()) for i in range(N)]
M = int(input())
t = [str(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 = [str(input()) for i in range(N)]
M = int(input())
t = [str(input()) for i in range(M)]
x = {}
for i in s:
    if i in x:
        x[i] += 1
    else:
        x[i] = 1
for i in t:
    if i in x:
        x[i] -= 1
    else:
        x[i] = -1
if max(x.values()) < 0:
    print(0)
else:
    print(max(x.values()))

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



ans = 0
scnt = 0
tcnt = 0
for s in S:
  scnt = 0 
  tcnt = 0 
  for tmps in S:
    if s == tmps: scnt += 1
  for t in T:
    if t == s: tcnt += 1
  ans = max(ans, scnt - tcnt)
  
print(max(0, ans))

Solution (Python):
import sys
from collections import Counter

n = int(input())
s_list = [input() for i in range(n)]
s_cntr = Counter(s_list)
m = int(input())
t_list = [input() for i in range(m)]
t_cntr = Counter(t_list)
ans = 0


for k in dict(s_cntr).keys():
    if k in dict(t_cntr).keys():
        tmp = s_cntr[k] - t_cntr[k]
    else:
        tmp = s_cntr[k]
    if ans < tmp:
        ans = tmp

print(ans)

Solution (Python):
D = dict()
N = int(input())
for i in range(N):
    s = input()
    if s in D.keys():
        D[s] += 1
    else:
        D[s] = 1
M = int(input())
for i in range(M):
    t = input()
    if t in D.keys():
        D[t] -= 1
ans = 0
for v in D.values():
    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)]
li = []

for i in range(n) :
    word = s[i]
    li.append(s.count(word) - t.count(word))
x = max(li)
if x <= 0 :
    print(0)
else :
    print(x)

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

word_set = set(S)
max_revenue = 0
for w in word_set:
  revenue = 0
  for s in S:
    if w == s:
      revenue += 1
  for t in T:
    if w == t:
      revenue -= 1
  if revenue > max_revenue:
    max_revenue = revenue

print(max_revenue)

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

b = {}
for i in range(N):
  s = str(input())
  if b.get(s) is None:
    b[s] = 1
  else:
    b[s] += 1
    
r = {}
M = int(input())
for i in range(M):
  s = str(input())
  if r.get(s) is None:
    r[s] = 1
  else:
    r[s] += 1

ans = -999999
for st in b:
  if r.get(st) is None:
    ans = max(ans, b[st])
  else:
    ans = max(ans, b[st] - r[st])
if ans >= 0:
  print(ans)
else:
  print(0)

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

Solution (Python):
def main():
  N = int(input())
  s = []
  for _ in range(N):
    s.append(input())
  M  = int(input())
  t = []
  for _ in range(M):
    t.append(input())
  
  su = list(set(s))
  ans = 0
  for row in su:
    point = s.count(row) - t.count(row)
    if ans < point:
      ans = point
  print(ans) 

main()

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

Solution (Python):
import sys
from collections import Counter
input = sys.stdin.readline

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


s = Counter(s)
t = Counter(t)
s.subtract(t)

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

Solution (Python):
N = int(input())
s = [input() for _ in [0]*N]
M = int(input())
t = [input() for _ in [0]*M]
ans = {}
for c in s:
    ans[c] = ans.get(c,0) + 1
for c in t:
    ans[c] = ans.get(c,0) - 1
print(max(0,max(ans.values())))

Solution (Python):
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
st = set(s+t)
ans = -10000

for i in st:
    count = 0
    for j in s:
        if i == j:
            count += 1
    for j in t:
        if i == j:
            count -= 1
    ans = max(ans, count)

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)]
m = 0
for i in list(set(s)):
  tmp = s.count(i) - t.count(i)
  if tmp > m:
    m = tmp
print(m)

Solution (Python):
dic_words = {}
for i in range(0, int(input())):
    word = input()
    if word in dic_words.keys():
        dic_words[word] += 1
    else:
        dic_words[word] = 1

for i in range(0, int(input())):
    word = input()
    if word in dic_words.keys():
        dic_words[word] -= 1
    else:
        dic_words[word] = -1

if (max(dic_words.values()) >= 0):
    print(max(dic_words.values()))
else:
    print(0)

Solution (Python):
red = []
blue = []

N = int(input())
for i in range(N):
    red.append(input())
    
M = int(input())
for i in range(M):
    blue.append(input())

counts = [red.count(word) - blue.count(word) for word in red]
ans = max(max(counts), 0)
print(ans)

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

ans = 0

for i in range(n):
    ans_n = 0
    for j in range(m):
        if sn[i]==sm[j]:
            ans_n -= 1
    for k in range(n):
        if sn[i]==sn[k]:
            ans_n += 1
    ans = max(ans, ans_n)

print(ans)

Solution (Python):
N=int(input())
N_list=list(map(str, list(input() for i in range (N))))
M=int(input())
M_list=list(map(str, list(input() for i in range (M))))


N_unique=list(set(N_list))

p_max=-101
for i in N_unique:
    p_max=max(p_max, N_list.count(i)-M_list.count(i))

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

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

X = 0
for i in range(N):
    temp = 0
    temp = s.count(s[i])
    for j in range(M):
        if s[i] == t[j]:
            temp -= 1
    X = max(X, temp)
print(X)

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

dict_s = {}
for i in range(N):
    if s[i] in dict_s:
        dict_s[s[i]] += 1
    else:
        dict_s[s[i]] = 1

dict_t = {}
for i in range(M):
    if t[i] in dict_t:
        dict_t[t[i]] += 1
    else:
        dict_t[t[i]] = 1

cnt=0
for i in dict_s:
    x = dict_s[i]
    if i in dict_t:
        x -= dict_t[i]
    if x >= cnt:
        cnt = x
print(cnt)

Solution (Python):
d = dict()
N = int(input())
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] = d[s] + 1
    else:
        d[s] = 1

M = int(input())
for i in range(M):
    s = input()
    if s in d.keys():
        d[s] = d[s] - 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)]

m = 0
c = 0
for i in range(N):
    w = s[i]
    c = s.count(w)
    c -= t.count(w)
    if m < c:
        m = c
print(m)

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

X = 0
check = []
for i in blue:
    yen = 0
    if i not in check:
        check.append(i)
        for j in blue:
            if j == i:
                yen += 1
        for j in red:
            if j == i:
                yen -= 1
    X = max(X, yen)

print(X)

Solution (Python):
from collections import Counter as c
import sys
input = sys.stdin.readline

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

S = c(S)
T = c(T)
ans = 0
for s in S:
    ans = max(ans,S[s]-T[s])
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 i in set(s):
  ans = max(ans, s.count(i)-t.count(i))
print(ans)

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

KEY = set(S + T)

max_point = 0
max_key = ""
for key in KEY:
	point = S.count(key) - T.count(key)
	if max_point < point:
		max_point = point
		max_key = key

print(max_point)

Solution (Python):
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = 0
di0 = {}
di1 = {}
for i in s:
  if(not i in di0):
    di0[i]=1
    di1[i]=0
  else:
    di0[i]+=1
for i in t:
  if(not i in di1):
    di1[i]=1
  else:
    di1[i]+=1
for i in di0:
  ans = max(di0[i]-di1[i],ans)
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))
ans=0
for i in s:
    key=0
    for j in s:
        if i==j:
            key+=1
    for j in t:
        if i==j:
            key-=1
    ans=max(ans,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)]

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)]
ans = []
for i in set(s):
  ans.append(s.count(i) - t.count(i))
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 = []
for i in set(s):
  ans.append(s.count(i) - t.count(i))
print(max(0,max(ans)))

Solution (Python):
n=int(input())
a=[input() for s in range(n)]
m=int(input())
b=[input() for t in range(m)]
aa=list(set(a))
bb=list(set(b))
aa.extend(bb)
category=list(set(aa))
c=[0]*len(category)
for i in a:
   for j in category:
       if i==j:
           c[category.index(j)]+=1
for i in b:
   for j in category:
       if i==j:
           c[category.index(i)]-=1
          
if max(c)<0:
    c.append(0)
print(max(c))

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

Solution (Python):
ls_t = [input().rstrip() for _ in range(int(input()))]
ls_s = [input().rstrip() for _ in range(int(input()))]
ls_marged = list(set(ls_t+ls_s))

result = 0

for word in ls_marged:
    t = ls_t.count(word)
    s = ls_s.count(word)
    result = max(result, t-s)

print(result)

Solution (Python):
N = int(input())
dct_t = {}

for _ in range(N):
    tmp = input().rstrip()
    if tmp in dct_t:
        dct_t[tmp] += 1
    else:
        dct_t[tmp] = 1

M = int(input())
dct_s = {}

for _ in range(M):
    tmp = input().rstrip()
    if tmp in dct_s:
        dct_s[tmp] += 1
    else:
        dct_s[tmp] = 1

result = 0

for t in list(dct_t.keys()):
    for s in list(dct_s.keys()):
        if t in dct_s:
            tmp = dct_t[t] - dct_s[t]
            if result < tmp:
                result = tmp
        elif result < dct_t[t]:
            result = dct_t[t]

print(result)

Solution (Python):
n = int(input())
li = []
li2 = []
li4 = []
c = 0

for i in range(n):
    s = input()
    li.append(s)
    li3 = set(li)
    
m = int(input())
for i in range(m):
    t = input()
    li2.append(t)

for a in li3:
    c = li.count(a)
    c -= li2.count(a)
    li4.append(c)

if max(li4) < 0:
    print(0)
else:
    print(max(li4))

Solution (Python):
from collections import Counter

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

sc = Counter(s)
tc = Counter(t)

ans = 0
for k in sc.keys():
    ans = max(ans, sc[k] - tc[k])
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)]

print(max(0, max(map(lambda z: z[1] - t.count(z[0]), Counter(s).items()))))

Solution (Python):
dict = {}
N = int(raw_input())
for i in range(N):
    blue = raw_input()
    if blue in dict: dict[blue] += 1
    else: dict[blue] = 1

M = int(raw_input())
for i in range(M):
    red = raw_input()
    if red in dict: dict[red] -= 1
    else: dict[red] = -1

if 0 < max(dict.values()): print max(dict.values())
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
for word in set(s):
    given = s.count(word) - t.count(word)
    ans = max(ans, given)
    
print(ans)

Solution (Python):
N = int(input())
words = []
s = []
for i in range(N):
    si = input()
    s.append(si)
    if si not in words:
        words.append(si)
M = int(input())
t = []
for i in range(M):
    ti = input()
    t.append(ti)
    if ti not in words:
        words.append(si)
ans = 0
for word in words:
    ans = max(ans, (s.count(word) - t.count(word)))
print(ans)

Solution (Python):
N=int(input())
S=[input() for _ in range(N)]
M=int(input())
T=[input() for _ in range(M)]
ans=0
SS=list(set(S))
for s in SS:
    score=S.count(s)-T.count(s)
    ans=max(ans,score)
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())
SS=list(set(S))
TS=list(set(T))
ans=0
for i in range(len(SS)):
    a=S.count(SS[i])
    b=T.count(SS[i])
    ans=max(ans,a-b)
print(ans)

Solution (Python):
Blue_card = [input() for i in range(int(input()))]
Red_card = [input() for i in range(int(input()))]
ans_list = [0]
for i in set(Blue_card):
    ans_list.append(Blue_card.count(i) - Red_card.count(i))
print(max(ans_list))

Solution (Python):
n=int(input())
arr1=[input() for _ in range(n)]
m=int(input())
arr2=[input() for _ in range(m)]
max=0
for i in range(n):
  tmp=arr1.count(arr1[i])-arr2.count(arr1[i])
  if tmp>max:
    max=tmp
print(max)

Solution (Python):


import sys
from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    blue = defaultdict(int)
    for _ in range(n):
        blue[SI()] += 1
        
    m = II()
    red = defaultdict(int)
    for _ in range(m):
        red[SI()] += 1

    res = 0
    for key, v in blue.items():
        res = max(res, v - red[key])

    return res


print(main())

Solution (Python):
N=int(input())
BLUE=[input() for i in range(N)]
M=int(input())
RED=[input() for i in range(M)]
List=list(set(list(set(BLUE))+list(set(RED))))
ans=0
for s in List:
  p=BLUE.count(s)
  m=RED.count(s)
  ans=max(ans,p-m)
print(ans)

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

c = 0

for i in range(n):
    a = 0
    b = 0
    for j in range(n):
        if s[i] == s[j]:
            a += 1

    for j in range(m):
        if s[i] == t[j]:
            b += 1

    if c < a-b:
        c = a-b

print(c)

Solution (Python):
from collections import defaultdict
from fractions import gcd

from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *

N=int(input())
B=defaultdict(int)
for i in range(N):
    s=input()
    B[s]+=1

M=int(input())
A=defaultdict(int)
for i in range(M):
    s=input()
    A[s]+=1
Max=0
for key in set(A) | set(B):
    Max=max(Max,B[key]-A[key])
print(Max)

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

ans = []
for i in st:
    tmp = 0
    tmp += s.count(i)
    tmp -= t.count(i)
    ans.append(tmp)
    
print(max(0, max(ans)))

Solution (Python):
N = int(input())
l={}
for _ in range(N):
    s = input()
    if s not in l:
        l[s] = 1
    else:
        l[s] += 1
M = int(input())
for _ in range(M):
    s = input()
    if s in l:
        l[s] -= 1
        
print(max(l.values()) if max(l.values()) >= 0 else 0)

Solution (Python):

import collections
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
c = collections.Counter(s) - collections.Counter(t)
if not c:
    print(0)
else:
    print(c.most_common()[0][1])

Solution (Python):
import collections
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]
smax=collections.Counter(s)
tmax=collections.Counter(t)
ans=[0]
for i,j in smax.items():
    if i in tmax.keys():
        ans+=[smax[i]-tmax[i]]
    else:
        ans+=[j]
print(max(ans))

Solution (Python):
N =int(input())
l1 =[input() for i in range(N)]
M =int(input())
l2 =[input() for i in range(M)]
dic = {'':0}
for v in (l1 + l2):
    dic[v] = l1.count(v) - l2.count(v)
print(max(dic.values()))

Solution (Python):
N = int(input())
blue = {}
for _ in range(N):
    s = input().rstrip()
    if blue.get(s) == None:
        blue[s] = 1
    else:
        blue[s] += 1
M = int(input())
red = {}
for _ in range(M):
    t = input().rstrip()
    if red.get(t) == None:
        red[t] = 1
    else:
        red[t] += 1
answer = 0
for i, blue_elem in blue.items():
    red_elem = red[i] if red.get(i) != None else 0
    answer = blue_elem - red_elem if answer < blue_elem - red_elem else answer
print(answer)

Solution (Python):

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

ans = [0]
for word in (blue + red):
    count = sum([s == word for s in blue])
    count -= sum([t == word for t in red])
    ans.append(count)

print(max(ans))

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

Solution (Python):
N =int(input())
AB=[[str(j) for j in input().split()] for i in range(N)]
M=int(input())
CD=[[str(j) for j in input().split()] for i in range(M)]
ans = 0
for i in AB:
    if ans < AB.count(i) -CD.count(i) :
        ans = AB.count(i) -CD.count(i)
print(ans)