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=[input() for i in range(int(input()))]
m=[input() for i 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()))]

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

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):
  _ = s.count(s[i])-t.count(s[i])
  x.append(_)
print(max(x))

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

s_set = set(s)
t_set = set(t)
can = s_set | t_set

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

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

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
cnt_dict = {}
for si in s:
    cnt_dict[si] = 0
for ti in t:
    cnt_dict[ti] = 0
for si in s:
  	cnt_dict[si] += 1
for ti in t:
    cnt_dict[ti] -= 1
print(max(max(cnt_dict.values()), 0))

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=[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=[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())
a = [str(input()) for _ in range(n)]
m = int(input())
b = [str(input()) for _ in range(m)]
l = set(a + b)
result = [0]
for i in l:
    result.append(a.count(i) - b.count(i))
print(max(result))

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())
dict_n={}
for _ in range(n):
    s = input()
    if s in dict_n:
        dict_n[s]+=1
    else:
        dict_n[s]=1
m=int(input())
dict_m={}
for _ in range(m):
    t = input()
    if t in dict_m:
        dict_m[t]+=1
    else:
        dict_m[t]=1
ans=0
for s in dict_n:
    if s in dict_m:
        ans=max(ans, dict_n[s]-dict_m[s])
    else:
        ans=max(ans, dict_n[s])
print(max(ans,0))

Solution (Python):
n = int(input())
sn = [input() for _ in range(n)]
m = int(input())
tm = [input() for _ in range(m)]
print(max([sn.count(x)-tm.count(x) for x in sn]+[0]))

Solution (Python):


n1=int(input())
n=[input() for i in range(n1)]
m1=int(input())
m=[input() for i in range(m1)]


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 = []
for _ in range(N):
    S.append(input())
M = int(input())
T = []
for _ in range(M):
    T.append(input())

res = 0
s = set(S)
for x in s:
    v = S.count(x)-T.count(x)
    if v >= res:
        res = v
print(res)

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 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 i in range(N)]
M=int(input())
t=[input() for i in range(M)]

sl=set(s)
tl=set(t)
c=sl|tl
cl=[]
for item in c:
    cl.append(max(0,s.count(item)-t.count(item)))
print(max(cl))

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

s_set = set(s)

points = []
for s_set_i in s_set:
    points.append(max(0, s.count(s_set_i) - t.count(s_set_i)))

print(max(points))

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

Solution (Python):
blue_list = []
red_list = []
diff_list = []

N = int(input())
for _ in range(N):
  blue_list.append(input())
M = int(input())
for _ in range(M):
  red_list.append(input())
  
for word in set(blue_list):
    diff_list.append(blue_list.count(word)-red_list.count(word))
    
print(max(0,max(diff_list)))

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

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

Solution (Python):
import collections
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
for i in range(M):
    if t[i] in s:
        s.remove(t[i])
if s ==list():
    print(0)
else:
    print(s.count(collections.Counter(s).most_common()[0][0]))

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

m = int(input())
m_list = [str(input()) for i in range(m)]

List = list(set(n_list))
print(max(0, max(n_list.count(List[i]) - m_list.count(List[i]) for i in range(len(List)))))

Solution (Python):

from collections import Counter
n = int(input())
n_dict = {}
for _ in range(n):
    ns = str(input().split())
    if ns not in n_dict.keys():
        n_dict[ns] = 1
    else:
        n_dict[ns] += 1

m = int(input())
m_dict = {}
for _ in range(m):
    ms = str(input().split())
    if ms not in m_dict.keys():
        m_dict[ms] = 1
    else:
        m_dict[ms] += 1

delta = dict(Counter(n_dict) - Counter(m_dict))
if len(delta)>0:
  ans = max(delta.values())
else:
  ans = 0
print(ans)

Solution (Python):
N=[input() for i in range(int(input()))]
M=[input() for i in range(int(input()))]
point={}

for i in N:
    if i not in point:
        point[i]=1
    else:point[i] +=1

for i in M:
    try:
        point[i] -=1
    except:continue

ans=max(point.values())
print(ans if ans>0 else 0)

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

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())
nlist = [input() for i in range(n)]
m = int(input())
mlist = [input() for j in range(m)]
r = 0
for nn in nlist:
    if nlist.count(nn) > mlist.count(nn) and r < nlist.count(nn) - mlist.count(nn):
        r = nlist.count(nn) - mlist.count(nn)
print(r)

Solution (Python):
import collections

def main():
    N = int(input())

    S = collections.defaultdict(int)
    for i in range(N):
        s = input()
        S[s] += 1
    
    M = int(input())
    for j in range(M):
        t = input()
        S[t] -= 1
    
    if max(S.values()) > 0:
        print(max(S.values()))
    else:
        print(0)

main()

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

for i in L:
    ans.append(s.count(i) - t.count(i))

print(max(0, max(ans)))

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

L = set(S)

ans = 0
for i in L:
    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)]

sdict = {k:s.count(k) for k in set(s)}
tdict = {k:t.count(k) for k in set(t)}

stkeys = set( list(sdict.keys()) + list(tdict.keys()) )

maxV = 0
for st in stkeys:
    sv = sdict[st] if st in sdict else 0
    tv = tdict[st] if st in tdict else 0
    maxV = max(maxV, sv-tv)

print(maxV)

Solution (Python):
d={}
for i in range(int(input())):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
        
for j in range(int(input())):
    t = input()
    if t in d:
        d[t] -= 1
    else:
        d[t] = -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)]

count = 0
for c in set(S):
    count = max(count, S.count(c) - T.count(c))

print(count)

Solution (Python):
from collections import Counter

n = int(input())
b = [input() for _ in range(n)]
m = int(input())
r = [input() for _ in range(m)]

db, dr = [Counter(x) for x in (b, r)]
print(max(*[v-dr[k] for k, v in db.items()]+[0]))

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

from collections import Counter
sc = Counter(s)
tc = Counter(t)

print(max(0, max([sc[i] - tc[i] for i in sc])))

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

s_dict = {}

for s_word in s:
    if s_word in s_dict:
        s_dict[s_word] += 1
    else:
        s_dict[s_word] = 1
        if s_word in t:
            s_dict[s_word] -= t.count(s_word)

max_count = max(s_dict.values())
if max_count < 0:
    max_count = 0
print(max_count)

Solution (Python):
n=int(input())
blue=[input() for i in range(n)]
m=int(input())
red=[input() for i in range(m)]
print(max(max([blue.count(blue[i])-red.count(blue[i]) for i in range(n)]),0))

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

Solution (Python):
s, t = [], []
d = {}

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

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

for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
for i in t:
    if i in d:
        d[i] -= 1
    else:
        d[i] = -1

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

Solution (Python):
import collections

n = int(input())
aol = [input() for i in range(n)]
m = int(input())
akal = [input() for j in range(m)]

aod = collections.Counter(aol)
akad = collections.Counter(akal)

l = [0]
for key in aod:
    if (key in akad) == True:
        sa = aod[key] - akad[key]
        l.append(sa)
    else:
        l.append(aod[key])

print(max(l))

Solution (Python):
n = int(input())
sL = [input() for i in range(n)]
m = int(input())
tL = [input() for i in range(m)]
L = list(set(sL))
maxnum = 0
for i in range(len(L)):
    num = max(0, sL.count(L[i])-tL.count(L[i]))
    if num > maxnum:
        maxnum = num
print(maxnum)

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):
from collections import defaultdict
d = defaultdict(int)

N = int(input())
a = list(input() for i in range(N))
M = int(input())
b = list(input() for i in range(M))

for i in range(N):
  d[str(a[i])] += 1

for i in range(M):
  d[b[i]] -= 1
print(max(d.values()) if max(d.values()) > 0 else 0)

Solution (Python):
n=[input() for i in range(int(input()))]
m=[input() for i 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())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
aa = list(set(a))
cnt = [0]
for i in aa:
  if b.count(i) >= 1:
    cnt.append(a.count(i)-b.count(i))
  else:
    cnt.append(a.count(i))
print(max(cnt))

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

cnt = 0
for i in range(N):
    tmp = s.count(s[i]) - t.count(s[i])
    if tmp > cnt:
        cnt = tmp
print(max(cnt, 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)]
cnt_s = Counter(s)
cnt_n = Counter(t)
cnt_s.subtract(cnt_n)
print(max(0, max(cnt_s.values())))

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

SNdict={}
TMdict={}

for name in SN:
    if name in SNdict.keys():
        SNdict[name]+=1
    else:
        SNdict[name]=1
for name in TM:
    if name in TMdict.keys():
        TMdict[name]+=1
    else:
        TMdict[name]=1
       
ret=0
for name in SNdict:
    tmp=0
    if name in TMdict.keys():
        tmp=TMdict[name]
    tmp=SNdict[name]-tmp
    ret=max(ret,tmp)
print(ret)

Solution (Python):
from collections import defaultdict


words_dict = defaultdict(int)
n = int(input())
for i in range(n):
    words_dict[input()] += 1

m = int(input())

for i in range(m):
    words_dict[input()] -= 1

ans = max(words_dict.values())
if ans < 0:
    ans = 0
print(ans)

Solution (Python):
n = int(input())
si = [input() for i in range(n)]
m = int(input())
ti = [input() for i in range(m)]
sik = set(si) 
tik =set(ti)
s=0
ma = 0
for i in sik:
    if si.count(i) - ti.count(i) > ma:  
        ma = si.count(i) -ti.count(i)
print(ma)

Solution (Python):
from collections import Counter

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

A = Counter(S)
B = Counter(T)

ans = 0
for k, v in A.items():
    if k in B.keys():
        v -= B[k]
    ans = max(v, ans)
print(ans)

Solution (Python):
nblues = int(input())
profits = dict()
for _ in range(nblues):
    word = input().rstrip("\n")
    profits[word] = profits.get(word, 0) + 1

nreds = int(input())
for _ in range(nreds):
    word = input().rstrip("\n")
    profits[word] = profits.get(word, 0) - 1

print(max(0, max(profits.items(), key=lambda t: t[1])[1]))

Solution (Python):
n = int(input())
blue = {}
for _ in range(n):
  s = input()
  if(s in blue):
    blue[s] += 1
  else:
    blue[s] = 1
m = int(input())
red = {}
for _ in range(m):
  t = input()
  if(t in red):
    red[t] += 1
  else:
    red[t] = 1
res = -100
for key, value in blue.items():
  tmp = 0
  if(key in red):
    tmp = blue[key] - red[key]
  else:
    tmp = blue[key]
  if(tmp > res):
    res = tmp
if(res >= 0):
  print(res)
else:
  print(0)

Solution (Python):
n = int(input())
can = []
for i in range(n):
  now = input()
  for j in range(len(can)):
    if now == can[j][0]:
      can[j][1] += 1
      break
  else:
    can.append([now,1])
m = int(input())
for i in range(m):
  now = input()
  for j in range(len(can)):
    if now == can[j][0]:
      can[j][1] -= 1
      break
maxi = 0
for j in range(len(can)):
  if can[j][1] > maxi:
    maxi = can[j][1]
print(maxi)

Solution (Python):
n = int(input())
s = [input()for _ in range(n)]
m = int(input())
t = [input()for _ in range(m)]
d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
for i in t:
    if i not in d:
        d[i] = -1
    else:
        d[i] -= 1
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
print(max(d[0][1], 0))

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

Solution (Python):
BlueN = int(input())
BlueList = []
for i in range(0,BlueN):
  BlueList.append(input())

RedN = int(input())
RedList = []
for i in range(0,RedN):
  RedList.append(input())

stocker = 0

for i in set(BlueList):
  if BlueList.count(i) * 1 + RedList.count(i) * -1 >= stocker:
    stocker = BlueList.count(i) * 1 + RedList.count(i) * -1

print(stocker)

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

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)
for x in s:
    d[x] += 1
for x in t:
    d[x] -= 1
print(max(0, max(d.values())))

Solution (Python):
from collections import Counter

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()
cnt_s = Counter(s)
cnt_t = Counter(t)
ans = [0]
cnt = 0
for i in range(len(cnt_s)):
    s_value = cnt_s.most_common()[i][0]
    s_count = cnt_s.most_common()[i][1]
    for j in range(len(cnt_t)):
        t_value = cnt_t.most_common()[j][0]
        t_count = cnt_t.most_common()[j][1]
        if s_value == t_value:
            ans.append(s_count-t_count)
            cnt = 1
            break
    if cnt == 0:
        ans.append(s_count)
    cnt = 0
print(max(ans))

Solution (Python):
n1 = int(input())
li1 = list(input() for i in range(n1))
n2 = int(input())
li2 = list(input() for i in range(n2))

prof = []
for i in range(n1):
    if li1[i] in li2:
        prof.append(li1.count(li1[i]) - li2.count(li1[i]))
    elif li1[i] not in li2:
        prof.append(li1.count(li1[i]))

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

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

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




from collections import Counter
S = Counter(s)

T = Counter(t)
x = S-T

count = (x.most_common(1))
try:
  if (count[0][1]):
    print(count[0][1])
except IndexError:
  print('0')

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

Solution (Python):
N=int(input())
Ni=[]
Mi=[]
Payoff=0
for i in range(N):
    Ni.append(input())
for i in range(int(input())):
    Mi.append(input())
for i in set(Ni+Mi):
    Payoff=max(Payoff, Ni.count(i)-Mi.count(i))
print(Payoff)

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
d['0'] = 0
n = int(input())
for i in range(n):
  d[input()] += 1 
m = int(input())
for i in range(m):
  d[input()] -= 1
print(max(d.values()))

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

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

yen = {}

for i in range(len(s)):
    if s[i] in yen:
        yen[s[i]] += 1
    else:
        yen[s[i]] = 1

for name in yen.keys():
    for i in t:
        if i == name:
            yen[name] -= 1

if max(yen.values()) < 0:
    print(0)
else:
    print(max(yen.values()))

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

import collections

s_count_dict = collections.Counter(s_list)
t_count_dict = collections.Counter(t_list)

max_count = 0
for s_word, s_count in s_count_dict.items():
    
    diff_count = s_count - t_count_dict[s_word] 
    if diff_count > max_count:
        max_count = diff_count

print(max_count)

Solution (Python):

from collections import Counter


if __name__ == '__main__':
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(m)]
    s_set = set(s)
    print(max(0, max([s.count(i) - t.count(i) for i in s_set])))

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]
cs=set(s)
a=0
for c in cs:
    if a<s.count(c)-t.count(c):
        a=s.count(c)-t.count(c)
print(a)

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


num_s = {key: 0 for key in list(set(s))}
for i in num_s.keys():
    num_s[i] = s.count(i)
for i in num_s.keys():
    num_s[i] -= t.count(i)

ans = max(num_s.values())
if ans < 0:
    print(0)
else:
    print(ans)

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

ans = 0

for i in lis:
    ans = max(ans,lis.count(i)-lit.count(i))

print(ans)

Solution (Python):
a = int(input())
b = [input() for i in range(a)]
c = int(input())
d = [input() for j in range(c)]
g = [0]*a
t = 0
for k in b:
    e = b.count(k)
    f = d.count(k)
    g[t] = e - f
    t +=1
if max(g) < 0:
    print(0)
else:
    print(max(g))

Solution (Python):
n = int(input())
b=[input() for _ in [0]*n]
m = int(input())
r=[input() for _ in [0]*m]
ans = 0
for s in set(b):
  ans = max([ans,b.count(s)-r.count(s)])
print(ans)

Solution (Python):
nN = int(input())
 
sListA = []
nListA = [ 0 for i in range(202)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
 
    
nN = int(input())
sListB = []
nListB = [ 0 for i in range(nN)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] -= 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] -= 1
 
nMax = max(nListA)

print(nMax)

Solution (Python):
nN = int(input())
 
sListA = []
nListA = [ 0 for i in range(202)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] += 1
 
    
nN = int(input())
sListB = []
nListB = [ 0 for i in range(nN)]
 
for i in range(nN):
  sTmp = input()
  if sTmp in sListA:
    nTmp = sListA.index(sTmp)
    nListA[nTmp] -= 1
  else:
    sListA.append(sTmp)
    nTmp = sListA.index(sTmp)
    nListA[nTmp] -= 1
 
nMax = max(nListA)

print(nMax)

Solution (Python):
 

from collections import Counter
n = int(input())
S = Counter([input() for i in range(n)])

m = int(input())
T = Counter([input() for i in range(m)])

diff = S - T
if diff:
    print(diff.most_common()[0][1])
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)]
st = s + t
d = {}
for i in range(n+m):
	d.setdefault(st[i],0)
for i in s:
	d[i] += 1
for i in t:
	d[i] -= 1

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

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

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

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

l=set(s)
num=max(s.count(i)-t.count(i) for i in l)
print(max(0,num))

Solution (Python):

n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(m)]

res = 0
for u in ss:
    tmp = ss.count(u) - tt.count(u)
    res = max(res, tmp)
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=[]

strset =set(s)
strlist = list(strset)

for i in strlist:
    ans.append(s.count(i)-t.count(i)) 

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)]
ansmx= -100
ans=0

strset =set(s)
strlist = list(strset)

for i in range(len(strlist)):
    str1=strlist[i]
    ans = s.count(str1)-t.count(str1)
    if ans>ansmx:
        ansmx = ans
if ansmx <0:
    print(0)
else:
    print(ansmx)

Solution (Python):
N = int(input())
s =[input() for i in range(N)]
M = int(input())
t =[input() for i in range(M)]
ansmx= -100
ans=0

strset =set(s+t)
strlist = list(strset)

for i in range(len(strlist)):
    str1=strlist[i]
    ans = s.count(str1)-t.count(str1)
    if ans>ansmx:
        ansmx = ans
if ansmx <0:
    print(0)
else:
    print(ansmx)

Solution (Python):
N = int(input())
S = list(input() for i in range(N))
M = int(input())
T = list(input() for i in range(M))
z = [0]

for s in S:
  z.append(S.count(s)-T.count(s))

print(max(z))

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

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())
s_cnt = Counter(s)
t_cnt = Counter(t)
ans_dict = {}
for key in s_cnt.keys():
    ans_dict[key] = s_cnt[key] - t_cnt[key]
print(max(max(ans_dict.values()), 0))

Solution (Python):
nm = int(input())
n = [input() for _ in range(nm)]
mm = int(input())
m = [input() for _ in range(mm)]
s = list(set(n))

print(max(0,max(n.count(s[i])-m.count(s[i]) for i in range(len(s)))))

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

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

ans_list = []

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

ans = max(0, max(ans_list))

print(ans)

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

for i in range(N):
    if s[i] in t:
        if s.count(s[i]) > t.count(s[i]):
            count = s.count(s[i]) - t.count(s[i])
            if count > ans:
                ans = count
    elif s[i] not in t:
        count = s.count(s[i])
        if count > ans:
            ans = count

print(ans)

Solution (Python):
from collections import Counter

c = Counter()
N = int(input())
for _ in range(N):
    s = input()
    c[s] += 1
M = int(input())
for _ in range(M):
    t = input()
    c[t] -= 1
print(max(0, c.most_common(1)[0][1]))

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))



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

from collections import Counter
sc = Counter(s)
tc = Counter(t)
ans = 0
for i in range(N):
  tmp = sc[s[i]] - tc[s[i]]
  if tmp > ans:
    ans = tmp
print(ans)

Solution (Python):
import math

n = int(input())







ls1 = [input() for i in range(n)]
m = int(input())
ls2 = [input() for i in range(m)]

ans = [0]

for i in ls1:
  ans.append(ls1.count(i) - ls2.count(i))
print(max(ans))

Solution (Python):
n=int(input())
a=[input() for _ in range(n)]
m=int(input())
b=[input() for _ in range(m)]
A=list(set(a))
ans=[0]
for i in range(len(A)):
    cnt=0
    cnt=a.count(A[i])-b.count(A[i])
    ans.append(cnt)
print(max(ans))

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

ans = 0
for i in a1:
    ans = max(ans, a1.count(i) - a2.count(i))
print(ans)

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

str2count1 = {}
for s in S:
    if s not in str2count1:
        str2count1[s] = 0
    str2count1[s] += 1

str2count2 = {}
for t in T:
    if t not in str2count2:
        str2count2[t] = 0
    str2count2[t] += 1

max_diff = 0
for key, value in str2count1.items():
    diff = value - str2count2[key] if key in str2count2 else value
    if max_diff < diff:
        max_diff = diff
print(max_diff)

Solution (Python):
N = int(input())
sList = [['' for i in range(1)] for j in range(N)]

for i in range(N):
    sList[i] = input()

M = int(input())
tList = [['' for i in range(1)] for j in range(M)]
for i in range(M):
    tList[i] = input()

ansMax = 0
for i in sList:
    tmp = sList.count(i) - tList.count(i)
    ansMax = max(ansMax, tmp)

print(ansMax)

Solution (Python):
dic = {}

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

M = int(input())
for j in range(M):
  i = input()
  if i in dic:
    dic[i] -= 1

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

Solution (Python):
dic = {}

N = int(input())
s = [input() for i in range(N)]
for i in range(N):
  dic.setdefault(s[i],0)
  dic[s[i]] += 1
  
M = int(input())
t = [input() for j in range(M)]
for j in range(M):
  dic.setdefault(t[j],0)
  dic[t[j]] -= 1

if max(dic.values()) > 0:
  print(max(dic.values()))
else:
  print(0)