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):
def function(values, num):
    count = int(input())

    for i in range(count):
        name = input()
        if name in values:
            values[name] += num
        else:
            values[name] = 1

    
if __name__ == '__main__':
    values = {}

    function(values, 1)
    function(values, -1)

    max_num = max(values.values())

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    c = collections.defaultdict(int)
    for _ in range(n):
        c[S()] += 1
    m = I()
    for _ in range(m):
        c[S()] -= 1

    return max(0, max(c.values()))


print(main())

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

max = 0
for i in set(s + t):
    sum = 0
    for j in s:
        if i == j:
            sum += 1
    for j in t:
        if i == j:
            sum -= 1
    if sum > max:
        max = sum

print(max)

Solution (Python):
wl = {}
N = int(input())
for n in range(N):
    w = input()
    if w in wl:
        wl[w] = wl[w]+1
    else:
        wl[w] = 1 
M = int(input())
for m in range(M):
    w = input()
    if w in wl:
        wl[w] = wl[w]-1
    else:
        wl[w] = -1

mc = ""
c = 0
for k, v in wl.items():
    if c < v:
        mc = k
        c = v

print(c)

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 = set(s_list)
t_set = set(t_list)

result = 0

for s in s_set:
  val = s_list.count(s) - t_list.count(s)
  if val > result:
    result = val

print(result)

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

ans = 0
for s in xs:
  sum = 0
  for t in xs:
    if s == t: sum += 1
  for t in ys:
    if s == t: sum -= 1
  ans = max(ans, sum)
print(ans)

Solution (Python):

if __name__ == "__main__":
    n = int(input())
    s = [ input() for _ in range(n) ]
    m = int(input())
    t = [ input() for _ in range(m) ]
    factors = list(set(s+t))
    dic = { key: 0 for key in factors}
    ans = float("-inf")
    for word in s:
        dic[word] += 1
    for word in t:
        dic[word] -= 1
    for word in list(set(s+t)):
        ans = max(ans, dic[word])
    else:
        if ans < 0:
            print(0)
        else:
            print(ans)

Solution (Python):
red = []
blue = []
ans = 0
n = int(input())
for _ in range(n):
    red.append(input())
m = int(input())
for _ in range(m):
    blue.append(input())
for word in set(red):
    if word in blue:
        tmp = red.count(word) - blue.count(word)
    else:
        tmp = red.count(word)
    if tmp > ans:
        ans = tmp
print(ans)

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

for word in set(red):
    r_num = red.count(word)
    if word in blue:
        tmp = r_num - blue.count(word)
    else:
        tmp = r_num
    if tmp > ans:
        ans = tmp
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)]

CounterS = Counter(S)
CounterT = Counter(T)

Max = 0
for key in CounterS.keys():
    i = int(CounterS.get(key, 0)) - int(CounterT.get(key, 0))
    if Max < i:
        Max = i
print(Max)

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

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

Solution (Python):

from collections import Counter
def inpl(): return tuple(map(int, input().split()))

N = int(input())
C = Counter()
for _ in range(N):
    C[input()] += 1
M = int(input())
for _ in range(M):
    C[input()] -= 1
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)]

ret = 0

for s in set(S):
    ret = max(ret, S.count(s) - T.count(s))

print(ret)

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

dicts = {}
for i in range(N):
    if(s[i] in dicts):
        dicts[s[i]] += 1
    else:
        dicts[s[i]] = 1
dictt = {}
for i in range(M):
    if(t[i] in dictt):
        dictt[t[i]] += 1
    else:
        dictt[t[i]] = 1

ans = 0
for i in range(N):
    if(s[i] in dictt):
        ans = max(dicts[s[i]] - dictt[s[i]], ans)
    else:
        ans = max(dicts[s[i]], ans)
print(ans)

Solution (Python):
N = int(input())
blue = ['a']*N

for i in range(0,N):
        blue[i] = input()
M = int(input())
red = ['a']*M

for i in range(0,M):
        red[i] = input()

set_blue = set(blue)
set_red = set(red)

tuple_blue = tuple(set_blue)
tuple_red = tuple(set_red)

max_score = 0
for i in range(0,len(tuple_blue)):
    score = blue.count(tuple_blue[i])-red.count((tuple_blue[i]))
    if max_score < score:
        max_score = score
print(max_score)

Solution (Python):






from sys import stdin

def multiset(xs, vocabulary=[]):
    d = {}
    for x in xs + vocabulary: d[x] = 0
    for x in xs: d[x] += 1
    return d

def solve(s, t):
    ss = multiset(s)
    tt = multiset(t, vocabulary=s)
    value = max([ss[x] - tt[x] for x in ss])
    return max(value, 0)

def readStrList():
    n = int(stdin.readline())
    s = []
    for i in range(n):
        x = stdin.readline().strip()
        s.append(x)
    return s

s = readStrList()
t = readStrList()
print(solve(s, t))

Solution (Python):
N=int(input() )
ans=0
S=[]
T=[]
S=[input() for i in range(0,N) ]
S.sort()
M=int(input() )
i=0
while i<M :
    T.append(input() )
    i=i+1
i=0
j=0
k=0
sans=0
while i<N :
    while S[i+k]==S[i] :
        k=k+1
        if(i+k==N):
            break
    j=0
    while j<M :
        if(S[i]==T[j]):
            sans=sans-1
        j=j+1
    sans+=k
    if(ans<sans):
        ans=sans
    sans=0
    i=i+k
    k=0
print(ans)

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

dic = {}

for i in range(n):
    word = input()

    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1

m = int(input())

for j in range(m):
    word = input()

    if word in dic:
        dic[word] -= 1
    else:
        dic[word] = -1


print(max(0,max(dic[x] for x in dic)))

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

temp = 0

for i in range(N):
    numN = 0
    numM = 0
    for j in range(N):
        if s[i]==s[j]:
            numN = numN + 1
    for k in range(M):
        if s[i]==t[k]:
            numM = numM + 1
    if temp <= numN-numM:
        temp=numN-numM

print(temp)

Solution (Python):
from collections import Counter


N = int(input())
S = Counter()
for _ in range(N):
    s = input()
    S.update([s])
M = int(input())
T = Counter()
for _ in range(M):
    t = input()
    T.update([t])

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

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

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


ans = 0
for n in range(N):
    count = 0
    for j in range(N):
        if s[n] == s[j]:
            count += 1
    for j in range(M):
        if s[n] == t[j]:
            count -= 1
    ans = max(ans, count)

print(ans)

Solution (Python):
s = []
t = []
x = []

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

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

for n in range(N):
    S = s.count(s[- n])
    T = t.count(s[- n])
    x.append(S - T)

for n in range(M):
    S = s.count(t[- n])
    T = t.count(t[- n])
    x.append(S - T)

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

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

m=int(input())
for _ in range(m):
    chara=input()
    if chara in d:
        d[chara]-=1
    else:
        d[chara]=-1

out=sorted(d.items(), key=lambda x: x[1])[-1][1]
if out<0:
    print(0)
else:
    print(out)

Solution (Python):


n=int(raw_input())
s=[]
t=[]
for i in xrange(n):
 s.append(raw_input())
m=int(raw_input())
for i in xrange(m):
 t.append(raw_input())
res=0
for i in xrange(n):
 res=max(res,s.count(s[i])-t.count(s[i]))
print res

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

m=int(input())
for i in range(m):
    blue.append(str(input()))

red_set=set(red)
ans = 0

for s in red_set:
    ans = max(ans,red.count(s)-blue.count(s))


print(ans)

Solution (Python):
from collections import defaultdict as dd

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

ans = 0
for s in po.values():
    if ans < s:
        ans = s
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)]

wordlist=list(set(s+t))
cnt=0
ss=Counter(s)
tt=Counter(t)
for i in wordlist:
    buf=ss[i]-tt[i]
    if cnt<buf:
      cnt=buf
      
print(cnt)

Solution (Python):
import pprint
from collections import defaultdict

N = int(input())

SD = defaultdict(int)
for _ in range(N):
    SD[input()] += 1

M = int(input())
TD = defaultdict(int)
for _ in range(M):
    TD[input()] += 1

KS = set(list(SD.keys()) + list(TD.keys()))

RL = [0]
for k in KS:
    RL.append(SD[k] - TD[k])

print(max(RL))

Solution (Python):
import copy
n = int(input())
s = []
for i in range(n):
    s += [input()]
checker = copy.deepcopy(s)
checker += ['xxxxxxxxxxxxxxxxxxxx']

m = int(input())
t = []
for i in range(m):
    t += [input()]

r = 0
for ss in set(checker):
    buf = s.count(ss) - t.count(ss)
    if r < buf:
        r = buf
print(r)

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

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

print(ans)

Solution (Python):
blue = []
red = []
count=countb=countr=x=maxi=0
nblue = int(input())
for c in range(1, nblue+1):
  blue+=[input()]
nred = int(input())
for c in range(1, nred + 1):
  red+=[input()]
for c in range (0, len(blue)): 
  countb=blue.count(blue[c])
  countr=red.count(blue[c])
  if countr>=1:
    countr=red.count(blue[c])
    countb-=countr
  if countb>maxi:
    maxi=countb
    x=c
print(maxi)

Solution (Python):
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]
u=set()
for i in range(N):
    u.add(s[i])
for i in range(M):
    u.add(t[i])
v=list(u)
w=[0 for i in range(len(v))]
for i in range(N):
    for j in range(len(w)):
        if s[i]==v[j]:
            w[j]+=1
for i in range(M):
    for j in range(len(w)):
        if t[i]==v[j]:
            w[j]-=1
print(max([0,max(w)]))

Solution (Python):
N=int(input())
a=list()
for i in range(0,N):
	x=input()
	a.append(x)
M=int(input())
b=list()
for i in range(0,M):
	x=input()
	b.append(x)
A=dict()
B=dict()
for i in a:
	x=a.count(i)
	A[i]=x
for i in b:
	x=b.count(i)
	B[i]=x
res=list()
for i in A:
	if i in B:
		A[i]-=B[i]
m=0


for i in A:
	if A[i]>m:
		m=A[i]

print(m)

Solution (Python):
blue=[]
red=[]
count=countb=countr=x=maxi=0
nblue=int(input())
for c in range(1,nblue+1):
  blue+=[input()]
nred=int(input())
for c in range(1,nred+1):
  red+=[input()]
for c in range(0,len(blue)):
  countb=blue.count(blue[c])
  countr=red.count(blue[c])
  if countr>=1:
    countr=red.count(blue[c])
    countb-=countr
  if countb>maxi:
    maxi=countb
    x=c
print(maxi)

Solution (Python):
n = int(input())
nlist = [input() for i in range(n)]
m = int(input())
mlist = [input() for i in range(m)]
 
for i in mlist:
    if i in nlist:
        nlist.remove(i)
 
def maxCOUNT( lis ):
  '''
  与えられたリストの中に、最も多く存在する要素を返す
  (最大の数の要素が複数ある場合、pythonのsetで先頭により近い要素を返す)
  '''
  L = lis[:]
  S = set(lis)
  S = list(S)
  MaxCount=0
 
  for elem in S:
    c=0
    while elem in L:
      ind = L.index(elem)
      foo = L.pop(ind)
      c+=1
    if c>MaxCount:
      MaxCount=c
  return MaxCount
 
print(maxCOUNT(nlist))

Solution (Python):















def main():
    N = int(input())
    S = tuple(input() for _ in [0] * N)
    M = int(input())
    T = tuple(input() for _ in [0] * M)

    blue = dict()
    for s in S:
        blue[s] = blue.get(s, 0) + 1

    red = dict()
    for t in T:
        red[t] = red.get(t, 0) + 1

    ans = 0
    for k, v in blue.items():
        if k in red:
            ans = max(ans, v - red[k])
        else:
            ans = max(ans, v)
    print(ans)

main()

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

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

c=[]
for i in range(N):
    d=a.count(a[i])
    e=b.count(a[i])
    c.append(d-e)

answer = max(c)

if answer>=0 :
    print(answer)
else :
    print(0)

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

M = int(input())
t = []
t_ = set([])
for j in range(M):
    tmp = input()
    t.append(tmp)
    t_.add(tmp)

u = s_.union(t_)

counter = []
for factor in u:
    v = s.count(factor) - t.count(factor)
    if v < 0:
        v = 0
    counter.append(v)
    

print(max(counter))

Solution (Python):
from collections import Counter

N=int(input())
N_s=[]
for i in range(N):
    N_s.append(input())
M=int(input())
M_t=[]
for j in range(M):
    M_t.append(input())
Monny_N=Counter(N_s)
Monny_M=Counter(M_t)

for key in Monny_N.keys():
    Monny_N[key] = Monny_N[key]-Monny_M[key]

Monny_max=max(Monny_N.values())

if Monny_max < 0:
    print("0")
else:
    print(Monny_max)

Solution (Python):
from collections import Counter

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

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

ls = Counter(s)
lt = Counter(t)

c = 0
for k in ls.keys():
    c_temp = ls[k] - lt[k]
    if c < c_temp:
        c = c_temp

print(c)

Solution (Python):
dict_list = {}

N = int(input())

for i in range(N):
	tmp = input()
	if tmp in dict_list.keys():
		dict_list[tmp] += 1
	else:
		dict_list[tmp] = 1

M = int(input())
for i in range(M):
	tmp = input()
	if tmp in dict_list.keys():
		dict_list[tmp] -= 1


answer = max(dict_list.values())
if answer < 0:
	print("0")
else:
	print(answer)

Solution (Python):
N=int(input())
Blue=[]
for I in range(N):
	Blue.append(input())
M=int(input())
Red=[]
for J in range(M):
	Red.append(input())
W=[]
Max=-101
for K in Blue:
	if K not in W:
		W.append(K)
		R=Blue.count(K)-Red.count(K)
		if R>Max:
			Max=R
if Max<=0:
	print(0)
else:
	print(Max)

Solution (Python):
def main():
    n = int(input())
    n_array = []
    for i in range(n):
        word = input()
        n_array.append(word)
    m = int(input())
    m_array = []
    for i in range(m):
        word = input()
        m_array.append(word)
    n_dic = {}
    m_dic = {}
    best = 0
    for i in n_array:
        if i in n_dic:
            n_dic[i] += 1
        else:
            n_dic[i] = 1
    for i in m_array:
        if i in m_dic:
            m_dic[i] += 1
        else:
            m_dic[i] = 1
    for i in n_dic:
        if i in m_array:
            if n_dic[i] - m_dic[i] > best:
                best = n_dic[i] - m_dic[i]
        else:
            if n_dic[i] > best:
                best = n_dic[i]
    print(best)

main()

Solution (Python):
s={}
t={}
num=0
n=input()
for i in range(int(n)):
  a=input()
  if a in s.keys():
    s[a]+=1
  else:
    s[a]=1
m=input()
for j in range(int(m)):
  b=input()
  if b in t.keys():
    t[b]+=1
  else:
    t[b]=1
for x in s.keys():
  y=s[x]
  if x in t.keys():
    y-=t[x]
  if y>num:
    num=y
print(str(num))

Solution (Python):

blue_dict = {}

N = int(input())
for _ in range(N):
    key = input()
    if key in blue_dict.keys():
        blue_dict[key] += 1
    else:
        blue_dict[key] = 1

M = int(input())
for _ in range(M):
    key = input()
    if key in blue_dict.keys():
        blue_dict[key] -= 1

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

Solution (Python):
from collections import defaultdict,Counter
N = input()
Ndic = defaultdict(int)
Mdic = defaultdict(int)
for i in range(int(N)):
    s = input()
    Ndic[s] += 1
M = input()
for j in range(int(M)):
    t = input()
    Mdic[t] += 1

ans = []
c = Counter(Ndic)
for k,v in c.most_common(1):
    mans = v
for k,v in c.most_common():
    if k in Mdic:
        ans.append(Ndic[k]-Mdic[k])
    else:
        ans.append(Ndic[k])

if ans:
    print(max(max(ans),0))
else:
    print(mans)

Solution (Python):
from collections import Counter

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

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


ss = list(set(s))


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




ans = 0
for i in range(len(ss)):
  wk = sc[ss[i]] - tc[ss[i]]
  if (ans < wk):
    ans = wk

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

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

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

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

ans = [0] * N

for i in range(N):
    for k in range(N):
        if INPn[i] == INPn[k]:
            ans[i] += 1
for i in range(N):
    for j in range(M):

        if INPn[i] == INPm[j]:
            ans[i] -= 1

for i in range(N):
    if ans[i] < 0:
        ans[i] = 0
        
mx = max(ans)
print(mx)

Solution (Python):

n = int(input())
blue = []
plus = []
for i in range(n):
    s = input()
    if s in blue:
        plus[blue.index(s)] += 1
    else:
        blue.append(s)
        plus.append(1)
m = int(input())
for i in range(m):
    s = input()
    if s in blue:
        plus[blue.index(s)] -= 1
    else:
        blue.append(s)
        plus.append(-1)
print(max(0, max(plus)))

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

Solution (Python):
from collections import Counter

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

c=Counter(s).most_common()
p=[]
for i in range(len(c)):
	p.append(c[i][1]-t.count(c[i][0]))
point=max(p)
if point<0:
	point=0
print(point)

Solution (Python):
blue_dict = {}
red_dict = {}

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

M = int(input())
for i in range(M):
    s = input()
    if s in red_dict:
        red_dict[s] = red_dict[s] + 1
    else:
        red_dict[s] = 1

point_max = 0
for s in blue_dict:
    point = blue_dict[s] - red_dict.get(s, 0)
    point_max = max(point_max, point)
print(point_max)

Solution (Python):
memo = {}

n = int(input())
for i in range(n):
    s = input().strip()
    if s not in memo:
        memo[s] = 1
    else:
        memo[s] += 1

n = int(input())
for i in range(n):
    s = input().strip()
    if s not in memo:
        memo[s] = -1
    else:
        memo[s] -= 1

res =  max(memo.values())
if res<0:
    res = 0

print(res)

Solution (Python):
from collections import defaultdict

blue = defaultdict(int)
red = defaultdict(int)

for i in range(int(input())):
    blue[input()] += 1

for i in range(int(input())):
    red[input()] +=1

max_key = max(blue.items(), key=lambda x:x[1]-red[x[0]])[0]

print(max(0, blue[max_key]-red[max_key]))

Solution (Python):
from collections import Counter, defaultdict
n = int(input())
s= []
t = defaultdict(int)
for _ in range(n):
    s.append(input())
u = Counter(s)
m = int(input())
for _ in range(m):
    word = input()
    t[word] -= 1
    if word in u.keys():
        u[word] -= 1

ans = u.most_common(1)[0][1]
t = sorted(t.items(), key=lambda x:x[1], reverse=True)[0][1]
t = max(t, 0)
print(max(ans,t))

Solution (Python):
from collections import Counter

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

ao_cnt = Counter(ao)

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

aka_cnt = Counter(aka)

ao_cnt.subtract(aka_cnt)
if ao_cnt.most_common(1)[0][1] <= 0:
    print(0)
else:
    print(ao_cnt.most_common(1)[0][1])

Solution (Python):
N = int(input())
L = {}
for i in range (N):
	a = input()
	if a in L :
		L[a] += 1
	else :
		L[a] = 1
M = int(input())
for i in range (M):
	a = input()
	if a in L and L[a] > 0:
		L[a] -= 1
	else :
		pass
maximum = 0
for i in L :
	if L[i] > maximum :
		maximum = L[i]
	else :
		pass
print (maximum)

Solution (Python):
from collections import Counter

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

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

s_count.subtract(t_count)

res = max(s_count.values())

if res > 0:
    print(res)
else:
    print(0)

Solution (Python):
from collections import Counter
import numpy as np

a = int(input())
a_list = []
b_list = []

for i in range(a):
  a_list.append(input())

b = int(input())

for i in range(b):
  b_list.append(input())
a_count = Counter(a_list)
b_count = Counter(b_list)
a_list_no_overlap = set(a_list)

point = []
for i in a_list_no_overlap:
    point.append(a_count[i]-b_count[i])

point_max = max(point)
if point_max<0:
  print(0)
else:
  print(point_max)

Solution (Python):
from collections import defaultdict

red_num = int(input())

str_dict = {}
for i in range(red_num):
    str = input()
    str_dict[str] = str_dict.get(str, 0) + 1

blue_num = int(input())

for i in range(blue_num):
    str = input()
    str_dict[str] = str_dict.get(str, 0) - 1

result = max(str_dict.values())

if result >= 1:
    print(result)
else:
    print(0)

Solution (Python):
N=int(input())
wordList={}
tmpWord=""
for i in range(N):
    tmpWord=input()
    if tmpWord in wordList:
        wordList[tmpWord]+=1
    else:
        wordList[tmpWord]=1
M=int(input())
for i in range(M):
    tmpWord=input()
    if tmpWord in wordList:
        wordList[tmpWord]-=1
if max(wordList.values())<=0:
    print("0")
else:
    print(max(wordList.values()))

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

m = int(input())
t = ["0"]*m
for i in range(m):
    t[i] = input()
    if t[i] in dict:
         dict[t[i]] -= 1
    else:
         dict[t[i]] = -1
    if dict[t[i]] < 0 :
         dict[t[i]] = 0
print(max(dict.values()))

Solution (Python):
import collections

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

count = collections.Counter()

for s in S:
    count[s] += 1
for t in T:
    count[t] -= 1
    
print(max(count.most_common(1)[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)]
ans=[]
import collections
data=collections.Counter(s)
deta=collections.Counter(t)
for i,j in data.items():
    for k,l in deta.items():
        if i==k:
            ans.append(j-l)
        if i not in t:
            ans.append(j)
if max(ans)<0:
    print(0)
else:
    print(max(ans))

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

n = int(input())						
for i in range(n):
	k = input()
	d[k] += 1

n = int(input())						
for i in range(n):
	k = input()
	d[k] -= 1



d = sorted(d.items(), key=lambda x: -x[1])
i = max(0, d[0][1])
print(i)

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

print(max)

Solution (Python):
from collections import Counter
N1 = int(input())
a = [input() for i in range(N1)]

N2 = int(input())
b = [input() for i in range(N2)]

counterA = Counter(a)
counterB = Counter(b)

counterA.subtract(counterB)
for c, d in counterA.most_common(1):
    print(max(0,d))

Solution (Python):
a = int(input())
blue = []
count = []
for i in range(a):
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b):
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

count.sort()
count.reverse()
if count[0] < 0:
    print("0")
else:
    print (count[0])

Solution (Python):
N = int(input())
words = [0 for i in range(0,N)]
for i in range(0,N):
    words[i] = input()
M = int(input())

for i in range(0,M):
    t = input()
    words.append(t)
SUM = []

for i in range(0,N+M):
    count = 0
    for j in range(0,N):
        if words[i] == words[j]:
            count += 1

    for j in range(N,N+M):
        if words[i] == words[j]:
            count -= 1
    SUM.append(count)


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

Solution (Python):
import sys

stdin = sys.stdin

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

n = ni()
s = []
for _ in range(n):
    s.append(ns())

m = ni()
t = []
for _ in range(m):
    t.append(ns())

ns = set(s)
ns = list(ns)
ts = [0]*len(ns)
for i in range(len(ns)):
    for j in s:
        if ns[i] == j:
            ts[i] += 1
    for j in t:
        if ns[i] == j:
            ts[i] -= 1
ts.sort(reverse=True)
if ts[0] > 0:
    print(ts[0])
else:
    print(0)

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

Solution (Python):
N = int(input())
S = {}
for i in range(N):
    s = input().rstrip()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

M = int(input())
for i in range(M):
    T = input().rstrip()
    if T in S:
        S[T] -= 1
        if S[T]==0:
            del S[T]


if len(S)==0:
    print('0')
else:
    print(max(list(S.values())))

Solution (Python):


N = int(input())
n = {}
for i in range(N):
    st = input()
    if st in n:
        n[st] += 1
    else:
        n[st] = 1
M = int(input())
m = {}
for i in range(M):
    st = input()
    if st in m:
        m[st] += 1
    else:
        m[st] = 1
maxl = 0
for st,i in n.items():
    if st not in m:
        maxl = max(i,maxl)
    else:
        maxl = max(i-m[st],maxl)

print(maxl)

Solution (Python):
from collections import Counter
N = int(input())
listBlue = [input() for i in range(N)]
M = int(input())
listRed = [input() for i in range(M)]

counterBlue = Counter(listBlue)
counterRed = Counter(listRed)
counterSum = counterBlue - counterRed
if len(counterSum) == 0:
    print(0)
else:
    ans = max(counterSum.values())
    print(ans)

Solution (Python):
from collections import Counter

n = int(input())
nl = [input() for i in range(n)]
m = int(input())
ml = [input() for j in range(m)]

ndict = dict(Counter(nl))
mdict = dict(Counter(ml))

difflist = []

for k1, v1 in ndict.items():
    if k1 in mdict:
        diff = v1 - mdict[k1]
        difflist.append(diff)
    else:
        difflist.append(v1)

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