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

from collections import Counter
CS=Counter(S)
CT=Counter(T)

ANS=0
for i in CS:
    if CS[i]-CT[i]>ANS:
        ANS=CS[i]-CT[i]

print(ANS)

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)]
c1 = Counter(S)
c2 = Counter(T)

ans = 0
for k,v in c1.items():
    tmp = v - c2[k]
    ans = max(ans, tmp)
print(ans)

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

d = {}

for i in range(N):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
    
for i in range(M):
    if t[i] in d:
        d[t[i]] -= 1
    else:
        d[t[i]] = -1

v = list(d.values())
v.append(0)
print(max(v))

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

Solution (Python):
from sys import stdin

dic = dict()


def main() -> None:
    n = next_int()
    register(n, 1)
    m = next_int()
    register(m, -1)

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

    print(ans)


def register(n: int, t: int) -> None:
    global dic
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += t
        else:
            dic[s] = t


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


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

S=set(s[i] for i in range(n))
L=len(S)
x = list(S)
a=[0]*(L+1)
for i in range(L):
    a[i]=s.count(x[i])-t.count(x[i])
print(max(a))

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

x = 0
for s in S:
    a = S.count(s)
    b = T.count(s)
    x = max(x, a-b)
print(x)

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

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

mc_s = Counter(s).most_common()
mc_t = Counter(t).most_common()

ans = []
for i in mc_s:
    for j in mc_t:
        if i[0] == j[0]:
            ans.append(i[1] - j[1])

ans = [0] * len(mc_s)
for i in range(len(mc_s)):
    ans[i] = mc_s[i][1]
    for j in range(len(mc_t)):
        if mc_s[i][0] == mc_t[j][0]:
            ans[i] = min(ans[i], mc_s[i][1] - mc_t[j][1])

ans.sort(reverse=True)
print(max(0,ans[0]))

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
word = set(s+t)
cou = 0
clist = []
for i in word:
  cou = s.count(i) - t.count(i)
  clist.append(cou)
ans = max(clist)
if ans < 0:
  ans = 0
print(ans)

Solution (Python):
n = int(input())
sd = {input():1}
for i in range(n-1):
    s = input()
    if s in sd:
        sd[s] += 1
    else:
        sd[s] = 1

m = int(input())
td = {input():1}
for i in range(m-1):
    t = input()
    if t in td:
        td[t] += 1
    else:
        td[t] = 1

for x in td:
    if x in sd:
        sd[x] -= td[x]

print(max(0,max(map(int, sd.values()))))

Solution (Python):
N = int(input())
s_list = []
for i in range(N):
  s_list.append(input())
M = int(input())
t_list = []
for i in range(M):
  t_list.append(input())
dict_index = set(s_list + t_list)
s_count = [s_list.count(i) for i in dict_index]
t_count = [t_list.count(i) for i in dict_index]
dict_count = [i - n for i, n in zip(s_count, t_count)]
if max(dict_count) < 0:
  print(0)
else:
  print(max(dict_count))

Solution (Python):
N=int(input())
dic={0:0}
for i in range(N):
    s=input()
    if dic.get(s,0)==0:
        dic[s]=1
    else:
        dic[s]+=1
M=int(input())
for i in range(M):
    s=input()
    if dic.get(s,0)!=0:
        dic[s]-=1
print(max(list(dic.values())))

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

p = set([] + s)

ans = 0
for x in p:
    ans = max(ans, s.count(x) - t.count(x))

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

Solution (Python):
dict = {}

n = int(input())

for i in range(n):
	s = input()
	try:
		dict[s] += 1
	except:
		dict[s] = 1

m = int(input())

for i in range(m):
	s = input()
	try:
		dict[s] -= 1
	except:
		dict[s] = -1

ans = sorted(dict.items(), key=lambda x: -x[1])

if ans[0][1] < 0:
	print(0)
else:
	print(ans[0][1])

Solution (Python):
dict = {}

n = int(input())

for i in range(n):
	s = input()
	try:
		dict[s] += 1
	except:
		dict[s] = 1

m = int(input())

for i in range(m):
	s = input()
	try:
		dict[s] -= 1
	except:
		dict[s] = -1

ans = sorted(dict.items(), key=lambda x: -x[1])

if ans[0][1] < 0:
	print(0)
else:
	print(ans[0][1])

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

S = sorted(set(s))
for _ in S:
  a = s.count(_) - t.count(_)
  if ans < a:
    ans = a

print(ans)

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

print(max(0, max([s.count(text)-t.count(text) for text in set(s) | set(t)])))

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

words = {}
for i in range(n):
    if not s[i] in words.keys():
        words[s[i]] = 1
    else:
        words[s[i]] += 1
for i in range(m):
    if not t[i] in words.keys():
        words[t[i]] = -1
    else:
        words[t[i]] -= 1

ans = 0
for k, v in words.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)]

Z = []
for si in S:
    Z.append(S.count(si) - T.count(si))
    
if max(Z) < 0:
    print("0")
else:
    print(max(Z))

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

maxs = 0

for si in s:
    tmp = s.count(si) - t.count(si)
    if tmp > maxs:
        maxs = tmp

print(maxs)

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

x = 0

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

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())
array=[]
for i in range(n):
    array.append(s.count(s[i])-t.count(s[i]))
if max(array)<0:
    print(0)
else:
    print(max(array))

Solution (Python):
a=[]
b=[]
m=0

for _ in [0]*int(input()):
  a += [input()]
for _ in [0]*int(input()):
  b += [input()]

for s in a:
  m = max(m, a.count(s)-b.count(s))
print(m)

Solution (Python):
from collections import Counter

N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
gain = 0

s_count = Counter(s)
t_count = Counter(t)
for s_str, s_num in s_count.items():
    if s_str not in t_count:
        gain = max(s_num, gain)
    elif s_num > t_count[s_str]:
        gain = max(s_num - t_count[s_str], gain)

print(gain)

Solution (Python):
import collections

n = int(input())

s = []

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

m = int(input())

t = []

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

l = list(set(s + t))

ans = 0

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

print(ans)

Solution (Python):
N = int(input())
Ns = []
for i in range(N):
    word = input()
    Ns.append(word)
M = int(input())
Ms = []
for i in range(M):
    word = input()
    Ms.append(word)
unique_words = list(set(Ns+Ms))
ans = 0
for word in unique_words:
    ans = max(ans,Ns.count(word)-Ms.count(word))
print(ans)

Solution (Python):
s = {}
t = {}
ans = 0
for i in range(int(input())):
    key = input()
    try:
        s[key] += 1
    except:
        s[key] = 1
for i in range(int(input())):
    key = input()
    try:
        t[key] += 1
    except:
        t[key] = 1
for key in s.keys():
    snum = s[key]
    tnum = 0
    try:
        tnum = t[key]
    except:
        pass
    ans = max(ans, snum - tnum)

print(ans)

Solution (Python):
n = int(input())
list_s = []
list_t = []
for i in range(0,n):
    list_s.append(str(input()))
m = int(input())
for i in range(0,m):
    list_t.append(str(input()))
ans = 0
for card in list_s:
    if ans < list_s.count(card) - list_t.count(card):
        ans = list_s.count(card) - list_t.count(card)
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 l in s:
    if s.count(l)-t.count(l)>ans:
        ans=s.count(l)-t.count(l)
print(ans)

Solution (Python):
N=int(input())
s=[]

for i in range(N):
  s1=input()
  s.append(s1)
M=int(input())
t=[]
for i in range(M):
  t1=input()
  t.append(t1)
s.sort()
t.sort()
u=[0]
for i in range(N):
  x=s.count(s[i])-t.count(s[i])
  u.append(x)
print(max(u))

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

max_profit = -100  
canditates = set(s_list)
for canditate in canditates:
    tmp_profit = s_list.count(canditate) - t_list.count(canditate)
    if tmp_profit > max_profit:
        max_profit = tmp_profit   
print(max(max_profit, 0))

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())
ans = ""
mon = 0
for i in range(n):
    if blue.count(blue[i]) - red.count(blue[i]) > mon:
        mon = blue.count(blue[i]) - red.count(blue[i])
print(mon)

Solution (Python):
N = int(input())
s = list([input() for i in range(N)])
M = int(input())
t = list([input() for i in range(M)])
union = list(set(s) | set(t))
l = [s.count(union[i])-t.count(union[i]) for i in range(len(union))]
if max(l) > 0:
  print(max(l))
else:
  print(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 k in s:
    d[k] += 1
for k in t:
    d[k] -= 1

maxv = sorted(d.values(), reverse=True)[0]
if maxv > 0:
    print(maxv)
else:
    print(0)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for j in range(m)]
c=0
for k in s:
  a=s.count(k)-t.count(k)
  if a>c:c=a
print(c)

Solution (Python):
N = int(input())
J = [input() for i in range(N)]
M = int(input())
K = [input() for i in range(M)]
L = []
Z = []
for i in range(len(J)):
  if (J[i] not in L):
    L.append(J[i])
for j in range(len(L)):
  p = J.count(L[j])
  q = K.count(L[j])
  Z.append(p-q)
Z.sort()
Z.reverse()
if (Z[0] <= 0):
  print('0')
else:
  print(Z[0])

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

pointList = dict();

for temp in s:
  pointList[temp] = 0
for temp in t:
  pointList[temp] = 0
  
for temp in s:
  pointList[temp] += 1
for temp in t:
  pointList[temp] -= 1
  
ans = max(0, max(pointList.values()))

print(ans)

Solution (Python):
n = int(input())
indexB =0
blueL =[]
while indexB<n:
    blueL.append(input())
    indexB+=1

m = int(input())
indexR =0
redL =[]
while indexR<m:
    redL.append(input())
    indexR+=1

blueL.sort()
length = len(blueL)
index1 =0
ansM=0
while index1<length:
    money =0
    for blueC in blueL:
        if blueL[index1] ==blueC:
            money+=1
    for redC in redL:
        if blueL[index1] ==redC:
            money-=1
    if ansM<money:
        ansM=money
    index1+=1

print(ansM)

Solution (Python):
N = int(input())
b_list = [input() for _ in range(N)]
b_set = set(b_list)
M = int(input())
r_list = [input() for _ in range(M)]
ans = 0

for i in b_set:
	ans = max(ans, b_list.count(i)-r_list.count(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)]

score = [0]

for s_test in s:
    scr = 0
    for ss in s:
        if ss == s_test:
            scr += 1
    for tt in t:
        if tt == s_test:
            scr -= 1
    score.append(scr)

ans = max(score)

print(ans)

Solution (Python):
n = int(input())
plus = {}

for i in range(n):
    a = input()
    if a in plus.keys():
        plus[a] += 1
    else:
        plus[a] = 1

m = int(input())
minus = {}
for i in range(m):
    a = input()
    if a in minus.keys():
        minus[a] += 1
    else:
        minus[a] = 1

mv = 0
for i in plus.keys():
    if i in minus.keys():
        t = plus[i] - minus[i]
    else:
        t = plus[i]
    mv = max(t, mv)

print(mv)

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


Max=-int(M)
for i in range(int(N)):
    point=int(0)
    str=Blue[i]
    for s in Blue:
        if s==str:
            point+=int(1)

    for s in Red:
        if s==str:
            point-=int(1)

    Max=max(Max,point)
print(max(Max,0))

Solution (Python):
S = []
T = []
ans = 0
N = int(input())
for i in range(N) :
    s = input()
    S.append(s)
M = int(input())
for j in range(M) :
    t = input()
    T.append(t)
for k in range(N) :
    if ans < S.count(S[k]) - T.count(S[k]) :
        ans = S.count(S[k]) - T.count(S[k])
print(ans)

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    s.append(input())
m=int(input())
t=[]
for j in range(m):
    t.append(input())
s1=set(s)
a=[]
for k in s1:
    a.append(s.count(k)-t.count(k))
if max(a)>=0:
    print(max(a))
else:print(0)

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

s_unique = list(set(s))


rieki = 0
son = 0
cnt = 0
res = 0
for i in s_unique:
    rieki = s.count(i)
    son = t.count(i)
    res = max(res, rieki - son)

print(res)

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)]
max=0
for i in range(N):
    cnt=0
    for j in range(N):
        if S[i]==S[j]:
            cnt+=1
    for k in range(M):
        if S[i]==T[k]:
            cnt-=1
    if max<cnt:
        max=cnt
print(max)

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

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

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

sets = set(s)

ans = [0]
for word in sets:
    tmp = 0
    tmp += s.count(word)
    tmp -= t.count(word)
    ans.append(tmp)

print(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 word in set(s):
    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

st=set(s+t)
for i in st:
    ans = max(s.count(i) - t.count(i) , 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)]
tmp = s_list.copy()
tmp.append("fdsfsdfsfs")
s_set = list(set(tmp))
result = []
for s in s_set:
    r = 0
    for i in s_list:
        if i == s:
            r += 1
    for j in t_list:
        if j == s:
            r -= 1
    result.append(r)
print(max(result))

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

for i in range(M):
    if t[i] in s:
        s.remove(t[i])

for i in range(len(s)):
    if sum < s.count(s[i]):
        sum = s.count(s[i])
print(sum)

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

for i in range(M):
    t.append(input())
mmax = -200
for i in s:
    m = 0
    for j in s:
        if i == j:
            m += 1
    for j in t:
        if i == j:
            m -= 1
    if mmax < m:
        mmax = m
    if mmax < 0:
        mmax = 0

print(mmax)

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

Solution (Python):
N = int(input())
card = {}
for i in range(N):
  S = input()
  card[S] = card.get(S, 0) + 1
 
M = int(input())
for i in range(M):
  S = input()
  card[S] = card.get(S, 0) - 1

tmp = list(card.values())
tmp.append(0)
print(max(tmp))

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

X = {}
for s in S:
  if s in X:
    X[s] += 1
  else:
    X[s] = 1

for t in T:
  if t in X:
    X[t] -= 1

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

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(input())
    M = int(input())
    T = []
    for _ in range(M):
        T.append(input())

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

if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import Counter
N = int(input())
blue = []
for i in range(N):
    blue.append(input())
M = int(input())
red = []
for j in range(M):
    red.append(input())
blue_Counter = Counter(blue)
red_Counter = Counter(red)
ans = blue_Counter - red_Counter
if not ans.most_common():
    print(0)
else:
    print(ans.most_common()[0][1])

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]




dp = None


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

    ans = -9999999999999

    for b in B:
        cnt = 0

        for bb in B:
            if b == bb:
                cnt += 1

        for r in R:
            if r == b:
                cnt -= 1

        ans = max(cnt, ans)

    print(max(ans, 0))


main()

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

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())

names = []
num = []

for i in range(N):
	s = input()
	if not s in names:
		names.append(s)
		num.append(1)
	else:
		ind = names.index(s)
		num[ind] += 1

M = int(input())

for i in range(M):
	s = input()
	if not s in names:
		names.append(s)
		num.append(-1)
	else:
		ind = names.index(s)
		num[ind] -= 1

print(max(max(num),0))

Solution (Python):
n=int(input())
s=[]
for i in range(n):
    s.append(input())
m=int(input())
for i in range(m):
    a=input()
    if(a in s):s.remove(a)
d=set(s)
ans=0
for i in d:
    ans=max(ans,s.count(i))
print(ans)

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

Solution (Python):
N = int(input())
S = []
for i in range(N) :
    s = input()
    S.append(s)
M = int(input())
T = []
for j in range(M) :
    t = input()
    T.append(t)
candidate = []
for k in range(len(S)) :
    counter1 = S.count(S[k])
    counter2 = T.count(S[k])
    counter = counter1 - counter2
    candidate.append(counter)
print(max(max(candidate),0))

Solution (Python):
from collections import Counter
N = int(input())
A = Counter(input() for _ in range(N))
M = int(input())
for _ in range(M):
    A[input()] -= 1

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

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

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

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

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
s.append('1')
m=int(input())
t=[input() for _ in range(m)]
t.append('1')
res = -float('inf')
for l in s:
    tmp = s.count(l)-t.count(l)
    res = max(res,tmp)
print(res)

Solution (Python):
from collections import Counter
N = int(input())
s1 = [input() for i in range(N)]
M = int(input())
s2 = [input() for i in range(M)]
c1 = Counter(s1)
c2 = Counter(s2)
ans = 0
for k in c1.keys():
    ans = max(ans, c1[k] - c2[k])
print(ans)

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

print(max(0, max([s.count(text)-t.count(text) for text in set(s) | set(t)])))

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_cand = [0]
for say in S:
    ans = 0
    for s in S:
        if say == s:
            ans += 1
    for t in T:
        if say == t:
            ans -= 1
        
    ans_cand.append(ans)
print(max(ans_cand))

Solution (Python):
from collections import Counter
N = int(input())
s1 = [input() for i in range(N)]
c1 = Counter(s1)
M = int(input())
s2 = [input() for i in range(M)]
c2 = Counter(s2)

ans = 0
for k,v in c1.items():
    ans = max(ans, v-c2[k])
print(ans)

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

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

    
max_count = 0
for i in range(N):
    for j in range(M):
        B = s.count(s[i]) - t.count(s[i])
        C = s.count(t[j]) - t.count(t[j])
        
        if B > C:
            E = B
        else:
            E = C
               
        if E > max_count:
            max_count = E
    
print(max_count)

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

d = {}
for k in s:
    if k in d.keys():
        d[k] += 1
    else:
        d[k] = 1
for k in t:
    if k in d.keys():
        d[k] -= 1
    else:
        d[k] = -1
print(max(max(d.values()),0))

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

Solution (Python):

from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
for _ in range(int(input())):
    d[input()] -= 1
print(max(max(d.values()),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)]

sc = Counter(s)
tc = Counter(t)
res = 0 
for s_key, s_value in zip(sc.keys(), sc.values()):
    t_value = tc[s_key]
    if s_value - t_value > res:
        res = s_value - t_value
print(res)

Solution (Python):
import collections
N = int(input())
blue = [list(input().split()) for i in range(N)]
M = int(input())
red = [list(input().split()) for i in range(M)]
sum =0
for i in blue:
    score = blue.count(i) - red.count(i)
    if score>sum:
        sum = score
print(sum)

Solution (Python):
N=int(input())
blue=[input() for i in range(N)]
M=int(input())
red=[input() for i in range(M)]
line=[]
for i in range(N):
    if blue[i]==0:
        continue
    else:
        c=0
        for j in range(1,N-i):
            if blue[i]==blue[i+j]:
                blue[i+j]=0
                c+=1
        for k in range(M):
                if red[k]==blue[i]:
                    c-=1
        else:
            line.append(c+1)
print(max(line) if max(line)>0 else 0)

Solution (Python):


def main():
    n = int(input())
    s_list = []
    for i in range(n):
        s_list.append(input())
    m = int(input())
    m_list = []
    for i in range(m):
        m_list.append(input())

    sen_set = set(s_list + m_list)
    max_money = 0
    for sen in sen_set:
        money = 0
        for i in s_list:
            if sen == i:
                money += 1
        for j in m_list:
            if sen == j:
                money -= 1
        if max_money < money:
            max_money = money
    
    print(max_money)



if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
N = int(input())
S = []
T = []
for i in range(N):
    S.append(input())
M = int(input())
for i in range(M):
    T.append(input())
ans = 0

CS = Counter(S)
CT = Counter(T)
A = [0]
for x in CS:
    if CS[x] > CT[x]:
        A.append(CS[x]-CT[x])
print(max(A))

Solution (Python):



def countDic(str_list):
    ret = {}
    for s in str_list:
        if s in ret.keys():
            ret[s] += 1
        else:
            ret[s] = 1
    return ret

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

s_c = countDic(s)
t_c = countDic(t)
a = []
for k in s_c.keys():
    if k in t_c.keys():
        a.append(s_c[k] - t_c[k])
    else:
        a.append(s_c[k])
if max(a) > 0:
    print(max(a))
else:
    print(0)

Solution (Python):
N = int(input())
dirB = {}
for _ in range(N):
    w = input()
    dirB[w] = dirB.setdefault(w, 0) + 1

M = int(input())
dirR = {}
for _ in range(M):
    w = input()
    dirR[w] = dirR.setdefault(w, 0) + 1
    
res = 0
for w in dirB:
    count = dirB[w] - dirR.setdefault(w, 0)
    if count > res:
        res = count
print(res)

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

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

Solution (Python):
N = int(input())
s = []
t = []
p = []
ans = 0
for i in range(0,N):
	s.append(input())
M = int(input())
for i in range(0,M):
	t.append(input())
for i in range(0,N):
	p.append(0)
	for j in range(0,N):
		if s[i] == s[j]:
			p[i] += 1
	for k in range(0,M):
		if s[i] == t[k]:
			p[i] -= 1
	if ans < p[i]:
		ans = p[i]
print(ans)

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

Solution (Python):
n = int(input())
s,t = list(),list()

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

m = int(input())

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

s.sort()
t.sort()

s_ = set(s)
t_ = set(t)

s_,t_ = list(s_),list(t_)
st_ = s_ + t_
st = set(st_)

res_list = list(st)
lo = len(res_list)
res_co = [0]*lo

for i in range(lo):
    res_co[i] += s.count(res_list[i])
    res_co[i] -= t.count(res_list[i])




if max(res_co) >= 0:
    print(max(res_co))
else:
    print(0)

Solution (Python):
N = int(input())
s_list = [input() for i in range(N)]
M = int(input())
t_list = [input() for i in range(M)]
X = 0
for i in range(N):
	X = max(X, s_list.count(s_list[i]) - t_list.count(s_list[i]))
print(X)

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


s2 = s[:]

set(s2)
ans = 0

for i in s2:
    if ans < s.count(i) - t.count(i):
        ans = s.count(i) - t.count(i)

print(ans)