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):
from collections import defaultdict

count = defaultdict(lambda: 0)

n = int(input())
for _ in range(n):
    count[input()] += 1
    
m = int(input())
for _ in range(m):
    count[input()] -= 1

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

Solution (Python):
if __name__ == '__main__':
    d = {}
    
    N = int(input())
    for si in range(N):
        si = input()
        if si in d.keys():
            d[si] += 1
        else:
            d[si] = 1
            
    M = int(input())
    for ti in range(M):
        ti = input()
        if ti in d.keys():
            d[ti] -= 1
        else:
            d[ti] = -1
    
    X = max(d.values())
    if X > 0:
        print(X)
    else:
        print(0)

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

m = int(input())
for i in range(m):
    s = input()
    if s in count:
        count[s] -= 1

print(max(list(count.values())+[0]))

Solution (Python):
s = [input() for i in range(int(input()))]
t = [input() for i in range(int(input()))]
import collections as cl
dic_s = cl.Counter(s)
dic_t = cl.Counter(t)
max_value = 0
for key in dic_s.keys():
  if key in dic_t:
    if dic_s[key] > dic_t[key]:
      max_value = max(dic_s[key] - dic_t[key], max_value)
  else:
    max_value = max(dic_s[key], max_value)
print(max_value)

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

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

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

a = 0
for x in list(set(s)):
    a = max(a, s.count(x) - t.count(x))

print(a)

Solution (Python):
def count(list, item):
    c = 0
    for i in list:
        if i == item:
            c += 1
    return c

def remove_item(list, item):
    list = [i for i in list if i != item]
    return list


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

while(len(s) != 0):
    
    w = s[0]
    n_s = count(s,w)
    n_t = count(t,w)
    
    if n_s - n_t > best:
        best = n_s - n_t
    
    s = remove_item(s,w)
    t = remove_item(t,w)

print(best)

Solution (Python):
from collections import Counter

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

c = Counter(s) - Counter(t)
if c:
    print(max(c.values()))
else:
    print(0)

Solution (Python):

import collections
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        s = [input() for _ in range(N)]
        M = int(input())
        t = [input() for _ in range(M)]
        s_c = collections.Counter(s)
        t_c = collections.Counter(t)

        ans = 0
        for k, s_v in s_c.items():
            t_v = t_c.get(k)
            if not t_v:
                ans = max(ans, s_v)
            else:
                ans = max(ans, max(0, s_v - t_v))
        print(ans)



if __name__ == '__main__':
    AtCoder().main()

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=float('-inf')
for i in range (n):
    sa=s.count(s[i])-t.count(s[i])
    ans=max(ans,sa)
if ans<0:
    print(0)
else:
    print(ans)

Solution (Python):
n=int(input())
nl=[input() for i in range(n)]
m=int(input())
ml=[input() for i in range(m)]
nsl=list(set(nl))
mx=0
for x in range(len(nsl)):
	d=nl.count(nsl[x])-ml.count(nsl[x])
	if d>mx:mx=d
print(max(0,mx))

Solution (Python):
N_1=int(input())
a={}
for i in range(N_1):
    fruit=input()
    count=0
    if fruit in a:
        a[fruit] +=1
    else:
        a[fruit]=1
        
N_2=int(input())
b={}
for i in range(N_2):
    fruit=input()
    count=0
    if fruit in b:
        b[fruit] +=1
    else:
        b[fruit]=1
c=[]
d=[]
max_num=0
for j,fruit_1 in a.items():
    for k,fruit_2 in b.items():
        if j == k:
            total=fruit_1-fruit_2
            c.append(total)
    if not j in b:            
        d.append(fruit_1)

if len(c) == 0 :
    max_num=max(d)
    

if len(d) == 0:
    max_num=max(c)

if len(c) !=0 and len(d) !=0:
    if max(c) > max(d) :
        max_num=max(c)
    else:
        max_num=max(d)
    
if max_num <0:
    max_num=0

print(max_num)

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

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

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

scores = []
for i in c:
    score = 0
    for j in range(n):
        if i == c[j]:
            score += 1
    for j in range(m):
        if i == d[j]:
            score -= 1
    scores.append(score)
if max(scores) >= 0:
    print(max(scores))
else:
    print(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[j])-M.count(L[j]) for j in range(len(L)))))

Solution (Python):
import collections

N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
c1 = collections.Counter(S)
answer = 0
for word in c1:
    count = c1[word] - T.count(word)
    answer = max(answer, count)
print(answer)

Solution (Python):
import collections

N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
c1 = collections.Counter(S)
c2 = collections.Counter(T)
answer = 0
for word in c1:
    if word in c2:
        count = c1[word] - c2[word]
    else:
        count = c1[word]
    answer = max(answer, count)
print(answer)

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

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

print(ans)

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

    dic_s = {}
    for i in range(N):
        if s[i] in dic_s:
            dic_s[s[i]] += 1
        else:
            dic_s[s[i]] = 1
            
    dic_t = {}
    for i in range(M):
        if t[i] in dic_t:
            dic_t[t[i]] += 1
        else:
            dic_t[t[i]] = 1
    
    ans = 0
    for c in list(dic_s):
        if c not in dic_t:
            ans = max(ans, dic_s[c])
            
        else:
            if dic_s[c] > dic_t[c]:
                ans  = max(ans, dic_s[c] - dic_t[c])
                
    print(ans)

if __name__ == "__main__":
    main()

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())
blue = [input() for i in range(n)]
m =int(input())
red = [input() for i in range(m)]
blue_x = list(set(blue))
ans = 0
for b in blue_x:
  ans = max(ans,blue.count(b)-red.count(b))
print(ans)

Solution (Python):
a=int(input())
b=list(input() for _ in range(a))
c=int(input())
d=list(input() for _ in range(c))
x=[]
for i in set(b):
  x+=[b.count(i)-d.count(i)]
print(max(max(x),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 p in s:
    cnt1=s.count(p)
    cnt2=t.count(p)
    ans=max(ans,cnt1-cnt2)
print(ans)

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

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

Solution (Python):
from collections import Counter as c;n,*s=open(0);n=int(n);print(max([0]+[v for v in(c(s[:n])-c(s[n+1:])).values()]))

Solution (Python):
from collections import*;a,b=eval('Counter([input()for _ in[0]*int(input())]),'*2);print(max([0]+[v for v in(a-b).values()]))

Solution (Python):
from collections import Counter
a=[input() for _ in range(int(input()))]
b=[input() for _ in range(int(input()))]
c=Counter(a)-Counter(b)
print(max([0]+[v for v in c.values()]))

Solution (Python):
def read_dict():
  n = int(input())
  c = {}
  
  for _ in range(n):
    s = input()
    if s in c:
      c[s] += 1
    else:
      c[s] = 1
  return c

blue = read_dict()
red = read_dict()

res = 0
for text in blue:
  to_add = blue[text]
  to_subtract = 0 if text not in red else red[text]
  res = max(res, to_add - to_subtract)
  
print(res)

Solution (Python):
import sys
from statistics import *
from collections import *
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
ct = 0
dic = {}
for i in range(n):
    s = input()
    if s not in dic.keys():
        dic[s] = 1
    else:
        dic[s] += 1
m = ni()
for i in range(m):
    t = input()
    if t in dic.keys():
        dic[t] -= 1
print(max(0, *dic.values()))

Solution (Python):
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]
point = 0
lst = list(set(s))

for i in range(len(lst)):
  tmp = s.count(lst[i]) - t.count(lst[i])
  if tmp > point:
    point = tmp

print(point)

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

Solution (Python):
from collections import*;C=Counter
n=int(input());c=C(input()for _ in range(n))
m=int(input());c.subtract(C(input()for _ in range(m)))
print(max(max(c.values()),0))

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

point = 0
set = list(set(s))
for i in range(len(set)):
    tmp = s.count(set[i]) - t.count(set[i])
    if tmp > point:
        point = tmp
print(point)

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

Solution (Python):


n = int(input())
blues = []
for i in range(n):
    blues.append(input())

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

variation = list(set(blues + reds))

patterns = [0]

for v in variation:
    patterns.append(blues.count(v) - reds.count(v))

print(max(patterns))

Solution (Python):
n = int(input())
a = [input() for i in range(n)]
m = int(input())
b = [input() for i in range(m)]
score = 0

for i in range(n):
    score = max(score, a.count(a[i])-b.count(a[i]))

print(score)

Solution (Python):
"""
【ABC091】
B - Two Colors Card Game



import sys


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))  
def MI(): return map(int, sys.stdin.readline().rstrip().split())        
def II(): return int(sys.stdin.readline().rstrip())                     
def S(): return sys.stdin.readline().rstrip()                           

N = II()
s = [S() for _ in range(N)]
M = II()
t = [S() for _ in range(M)]
max = 0
for x in set(s):
    a = s.count(x)
    b = t.count(x)
    if max < a - b:
        max = a - b
print(max)

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

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

for i in range(m):
    if t[i] in dic:
        dic[t[i]] -= 1


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

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

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

ans = 0
for i in set(s):
  if s.count(i) - t.count(i) > ans:
    ans = s.count(i) - t.count(i)

print(ans)

Solution (Python):
from collections import Counter
n = int(input())
s = [input().rstrip() for _ in range(n)]
m = int(input())
t = [input().rstrip() for _ in range(m)]
sc = Counter(s)
tc = Counter(t)
for k in tc:
    sc[k] -= tc[k]

mc = sc.most_common(1)
if len(mc) and mc[0][1] > 0:
    print(mc[0][1])
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))
ss = set(s)
ans = []

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

print(max(0, max(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))
ss = set(s)
ans = []

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

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

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

sset = list(set(s)) 
count = [s.count(sset[i]) - t.count(sset[i]) for i in range(len(sset))] 
ans = max(0, max(count)) 

print(ans)

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

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

print(ans)

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

S_set = list(set(S))
score = 0

for s in S_set:
  x = S.count(s)
  y = T.count(s)
  if x - y > score:
    score = x - y
print(score)

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

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

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
ans = 0
for ws0 in s:
    point = 0
    for ws1 in s:
        if ws0 == ws1:
            point += 1
    for wt in t:
        if ws0 == wt:
            point -= 1
    ans = max(ans, point)
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)]

S_set = {s:0 for s in S}
T_set = {t:0 for t in T}
for s in S:
  S_set[s] += 1
for t in T:
  T_set[t] += 1

  
ans = 0
for s in S_set.keys():
  if s in T_set.keys():
    pool = S_set[s] - T_set[s]
  else:
    pool = S_set[s]
  if pool > ans:
    ans = pool
print(ans)

Solution (Python):
N = int(input())
red_counts = {}
for i in range(N):
    r = input()
    if r in red_counts:
        red_counts[r] += 1
    else:
        red_counts[r] = 1
M = int(input())
blue_counts = {}
for i in range(M):
    b = input()
    if b in blue_counts:
        blue_counts[b] += 1
    else:
        blue_counts[b] = 1
        
ans = 0
for k in red_counts.keys():
    if k in blue_counts:
        ans = max(ans, red_counts[k] - blue_counts[k])
    else:
        ans = max(ans, red_counts[k])
print(ans)

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

result = {}
for word in set(s):
  result[word] = s.count(word)
    
M = int(input())
for _ in range(M):
  w = input()
  if w in set(s):
    result[w]-=1

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

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

m = int(input())
for j in range(m):
    red.append(input())

ans = 0
red_set = set(red)
blue_set = set(blue)
for b in blue_set:
 for r in red_set:
     ans = max(ans,blue.count(b)-red.count(b))
print(ans)

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

Solution (Python):
def resolve():
    n = int(input())
    s = list(input() for _ in range(n))
    m = int(input())
    t = list(input() for _ in range(m))
    words = set(s)
    ans = []
    for w in words:
        ans.append(s.count(w) - t.count(w))
    print(max(ans) if max(ans) > 0 else 0)


if __name__ == "__main__":
    resolve()

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

s_set = list(set(s))
ans = 0
for name in s_set:
    count = s.count(name) - t.count(name)
    ans = max(count, ans)

print(ans)

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
s = dict(collections.Counter(s).most_common())
t = dict(collections.Counter(t).most_common())
m_cnt = 0
for k, v in s.items():
    if k in t:
        if v > t[k]:
            if m_cnt < v - t[k]:
                m_cnt = v - t[k]
    else:
        if m_cnt < v:
            m_cnt = v
print(m_cnt)

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

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

n=int(input())
for _ in range(n):
  r=input()
  if r in dic:
    dic[r]-=1
  else:
    dic[r]=-1

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

Solution (Python):

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

s_set = set(s)

ans = 0
for card in s_set:
    count = s.count(card) - t.count(card)
    ans = max(count, ans)

print(ans)

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

col = collections.Counter(s)

c = col.most_common()

ansl = []
for i in range(len(c)):
	ss = s.count(c[i][0])
	tt = t.count(c[i][0])
	ansl.append(ss - tt)
	
	
if max(ansl) < 0:
	ans = 0
else:
	ans = max(ansl)

print(ans)

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+t))
cnt = []

for i in range(len(st)):
  cnt.append(0)

for i in range(len(st)):
  cnt[i] = s.count(st[i]) - t.count(st[i])

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

Solution (Python):
nlst = [input() for _ in range(int(input()))]
mlst = [input() for _ in range(int(input()))]
point = max([nlst.count(i) - mlst.count(i) for i in set(nlst)])
print(point if point >= 0 else 0)

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

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

a = Counter(s)
b = Counter(t)

maxvalu = 0

for k,v in a.items():
    ans = a[k]
    if k in b:
        ans -= b[k]
    maxvalu = max(maxvalu,ans)

print(maxvalu)

Solution (Python):
def main():
    N = int(input())
    d = dict()
    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

    max_v = 0
    for t in d:
        max_v = max(max_v, d[t])
    return max_v

if __name__ == '__main__':
    print(main())

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

a=0
max=0
for i in set(s):
    a=(s.count(i)-t.count(i))
    if a>max:
        max=a
print(max)

Solution (Python):
from collections import defaultdict

n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)

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

uniq=list(set(ss+ts))

cost=[]
for u in uniq:
  cost.append(ss.count(u)-ts.count(u))

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

Solution (Python):
from collections import Counter


def main():
    count_by_kw = Counter()
    n = int(input())
    for i in range(n):
        key = input()
        count_by_kw[key] += 1

    m = int(input())
    for i in range(m):
        key = input()
        count_by_kw[key] -= 1
    print(max(0, count_by_kw.most_common(1)[0][1]))


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 = list(set(s))
ans = 0
for card in s_set:
    count = s.count(card) - t.count(card)
    ans = max(count, ans)

print(ans)

Solution (Python):
card = {}

for _ in range(int(input())):
    key = input()
    card[key] = card.get(key, 0) + 1

for _ in range(int(input())):
    key = input()
    card[key] = card.get(key, 0) - 1

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

print(max(sorted_card[0][1], 0))

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

dic={}
for i in s:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1

for i in t:
    if i in dic:
        dic[i]-=1
ma=max(dic.values())
print(max(ma , 0))

Solution (Python):
n = int(input())
s = {}
for _ in range(n):
    cur = input()
    val = s.get(cur,0) + 1
    s[cur] = val
m = int(input())
t = {}
for _ in range(m):
    cur = input()
    val = t.get(cur,0) + 1
    t[cur] = val
s = list(s.items())
s.sort(key=lambda x:x[1],reverse=True)

ans = 0
for key,point in s:
    cur = point
    if key in t.keys():
        cur -= t[key]
    if ans < cur:
        ans = cur

print(ans)

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

print(max(list))

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)]
print(max([0]+[s.count(s[i])-t.count(s[i]) for i in range(n)]))

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 i in range(int(input()))]
m = [input() for i in range(int(input()))]
lst = []
for i in range(len(n)):
    lst.append(n.count(n[i])-m.count(n[i]))
print(max(max(lst),0))

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

m = int(input())
for i in range(m):
  t = input()
  if t in dic.keys():
    dic[t] -= 1
    
ans = 0
for key in dic.keys():
  ans = max(ans, dic[key])
  
print(max(ans, 0))

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

ans=0
for k,v in a.items():
    tmp=v
    if k in b:
        tmp-=b[k]
    ans=max(ans, tmp)
print(ans)

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

l = list(set(s))

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

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

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

count = {}

for s in ss:
  if s in count:
    count[s] += 1
  else:
    count[s] = 1

for t in ts:
  if t in count:
    count[t] -= 1
  else:
    count[t] = -1
    
print(max(max(count.values()), 0))

Solution (Python):
num_red = int(input())
red = [0] * num_red

for i in range(num_red):
    red[i] = input()

num_blue = int(input())
blue = [0] * num_blue

for i in range(num_blue):
    blue[i] = input()

max = 0
count = 0

for i in range(num_red):
    if red.count(red[i]) > 0:
        count += red.count(red[i])

    for x in range(num_blue):
        if red[i] == blue[x]:
            count -= 1
    if count > max :
        max = count

    count = 0

print(max)

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

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

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

print(ans)

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

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

Solution (Python):
from collections import defaultdict

d = defaultdict(int)
n = int(input())
for _ in range(n):
    d[input()] += 1
m = int(input())
for _ in range(m):
    d[input()] -= 1

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

Solution (Python):
dic = {}
for _ in range(int(input())):
    s = input()
    if s in dic:
        dic[s] +=1
    else:
        dic[s] = 1
for _ in range(int(input())):
    t = input()
    if t in dic and 1 < dic[t]:
        dic[t] -=1
    else:
        dic[t] = 0
print(max(dic.values()))

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

Solution (Python):
N = int(input())
d ={}
for i in range(N):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
M = int(input())
for j in range(M):
  a = input()
  if a in d:
    d[a] -= 1
  else:
    d[a] = -1
li = d.values()
print(max(li) if max(li) >= 0 else 0)

Solution (Python):
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
s = [ns() for _ in range(n)]
m = ni()
t = [ns() for _ in range(m)]
ans = 0
for word in set(s):
        point = s.count(word) - t.count(word)
        ans = max(point, ans)

print(ans)

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

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

max_count=0
for word in set(n_list):
    count=n_list.count(word)-m_list.count(word)
    if max_count<count:
        max_count=count
print(max_count if max_count>0 else 0)

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

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

scores = []
for i in s:
    scores.append(s.count(i) - t.count(i))

print(max(scores) if max(scores) > 0 else 0)

Solution (Python):
N=int(input())
Blue=[ input() for i in range(N)]
M=int(input())
Red=[ input() for i in range(M)]
L=[0]
for b in set(Blue):
  L.append(Blue.count(b)-Red.count(b))
print(max(L))

Solution (Python):
N=int(input())
sN=[input() for _ in range(N)]
M=int(input())
tM=[input() for _ in range(M)]
Max=0
for s in list(set(sN)):
  Max = max(sN.count(s) - tM.count(s), Max)
print(max(Max, 0))

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

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

keyl=[]
bluedic={}
reddic={}
for st in sl :
  if st in bluedic.keys() :
    bluedic[st]=bluedic[st]+1
  else :
    bluedic[st]=1
for st in tl :
  if st in reddic.keys() :
    reddic[st]=reddic[st]+1
  else :
    reddic[st]=1
keyl=list(bluedic.keys())

mx=0
for k in keyl :
  if not k in reddic.keys() :
    reddic[k]=0
  div=(bluedic[k]-reddic[k])
  if mx < div :
    mx=div
    
print(mx)

Solution (Python):
n=int(input())
c=0
dic={}
for i in range(n):
    x=input()
    if x not in dic:
        dic[x]=1
    else:
        dic[x]+=1
m=int(input())
for i in range(m):
    x=input()
    if x in dic:
        dic[x]-=1

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